I have multiple Playerid.. (1 to 37) how can i incorperate this into the stored procedure.. I could hard code all 37 but when an increase is players i would have to modify every single time.
Below is the stored procedure i have create..
CREATE Procedure sp_influenceTES T
@PlayerID int
As
select gameid as gameidIn, result as resultIn
into #Ingameid
from results
where playerid = @PlayerID
order by gameid asc
select *
into #Inallgames
from #Ingameid
left join results
on #Ingameid.gamei dIn = results.gameid and #Ingameid. resultIn = results.result
order by #Ingameid.gamei dIn
create table #Inall (playerid decimal(5), allgame decimal(5))
insert into #Inall
select #Inallgames.pla yerid, count(#Inallgam es.playerid) as count
from #Inallgames
where #Inallgames.pla yerid <> @PlayerID
group by #Inallgames.pla yerid
order by count desc
create table #Inwon (playerid decimal(5), wongames decimal(5))
insert into #Inwon
select #Inallgames.pla yerid, count(#Inallgam es.playerid) as count
from #Inallgames
where #Inallgames.pla yerid <> @PlayerID
and #Inallgames.res ult = 1
group by #Inallgames.pla yerid
order by count desc
create table #Inallwon (playerid decimal(5), wongame decimal(5), allgames decimal(5))
insert into #Inallwon
select #Inall.playerid , #Inwon.wongames , #Inall.allgame
from #Inall
left join #Inwon
on #Inall.playerid = #Inwon.playerid
select #Inallwon.wonga me, #Inallwon.allga mes, wongame / allgames as percentage
into #InallwonP
from #Inallwon
order by percentage desc
select sum(percentage) as InfluenceValue into #influenceValue from #InallwonP
select sum(allgames) as allgames into #Influenceallga mes from #Inallwon
create table #InfluencePlaye rID (playerid decimal(5))
insert #InfluencePlaye rID values (@PlayerID)
create table #Influence (Playerid decimal(5), Allgames decimal (5), InfluenceValue float (5))
insert into #Influence
select #InfluencePlaye rID.playerid, #Influenceallga mes.allgames, #InfluenceValue .influencevalue
from #InfluencePlaye rID, #Influenceallga mes, #InfluenceValue
select *
from #influence
loop
GO
0 1153 Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Michael Trosen |
last post by:
Hi Everyone,
I hope someone can help, I'm pretty new to pro*c programming.
I have the following application setup:
a pro*c program calls a stored procedure and recieves a cursor back:
the cursor is defined as: SQL_CURSOR delpt_cursor
|
by: Thomas R. Hummel |
last post by:
I have a stored procedure that suddenly started performing horribly.
The query plan didn't look right to me, so I copy/pasted the code and
ran it (it's a single SELECT statement). That ran pretty well and used
a query plan that made sense. Now, I know what you're all thinking...
stored procedures have to optimize for variable parameters, etc.
Here's what I've tried to fix the issue:
1. Recompiled the stored procedure
2. Created a new,...
|
by: James Foreman |
last post by:
I'm building a stored procedure that simulates cars arriving in a car
park, and staying for different amounts of time, based on historical
data.
So, first I define a cursor that's populated by querying last year's
bookings for the period that I'm interested in. This is about 6,500
bookings.
The sp then looks at the first booking and compares it to how many cars
are already in the car park. If adding that booking would violate the
|
by: Rhino |
last post by:
I am trying to determine the behaviour of stored procedures in DB2 V8.2.x in
Windows/Unix/Linux and how I can control that behaviour. Some documentation
in the manuals is confusing the issue somewhat.
First, am I right in understanding that the normal behaviour of a stored
procedure, fenced or unfenced, is to only go into memory when it is invoked
and to be swapped out of memory when it is not needed any more?
Second, am I right in...
|
by: James Wong |
last post by:
Hi,
I am writing a vb.net2005 program that needs to create a stored procedure
with SqlServerProject Template.
Now, I have two questions for this stored procedure.
1) How can I import and execute the .dll in this Stored Procedures?
2) How can I connect the Web Service and get the result in this Stored
Procedures?
| |
by: pinney.colton |
last post by:
I would like to create a stored procedure which creates a temp table to
store some XML. The # of fields of XML is dependent upon the contents
of another table in the application, so the first part of my procedure
identifies the # of fields necessary. That is working correctly. The
second part of the procedure actually attempts to create the table.
This is where my issue is.
If I attempt to create the table as a non-temporary table,...
|
by: nishi57 |
last post by:
I hope I can get some help regarding this issue, which has been going
on for a while. I have a desktop user who is having problem running
"Stored Procedures". The DB2 Connect application works fine but when he
runs the stored procedure, he gets the following error message.
"SYSPROC".CSGCSB54 - Run started.
Data returned in result sets is limited to the first 100 rows.
Data returned in result set columns is limited to the first 20...
|
by: satish mullapudi |
last post by:
Hi,
I am using DB2 v8.2 & jdk 1.5. I have written a Hello World program in
java. Now is it possible to call the HelloWorld program from a stored
procedure ? If so, how? I want to catch the result returned by the java
program into the stored procedure.
Please help out in this regard
Thanks in advance........
Satish....
|
by: william.david.anderson |
last post by:
Hi there,
I have a newbie question regarding stored procedures and locking.
I'm trying to use a stored
procedure to perform a 'select for update' and return a cursor.
Below is a stripped down version
of the procedure:
CREATE PROCEDURE SELBTFLFORUPDATE()
LANGUAGE SQL
|
by: gopi2ks |
last post by:
Dear All,
I have one stored procedure like sp_insertEmployee
Employee Table Fileds
Eno int pk,
ename varchar(100),
designation varchar
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |