473,385 Members | 1,772 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Stored procedure issue!

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_influenceTEST

@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.gameidIn = results.gameid and #Ingameid. resultIn = results.result
order by #Ingameid.gameidIn

create table #Inall (playerid decimal(5), allgame decimal(5))

insert into #Inall
select #Inallgames.playerid, count(#Inallgames.playerid) as count
from #Inallgames
where #Inallgames.playerid <> @PlayerID
group by #Inallgames.playerid
order by count desc

create table #Inwon (playerid decimal(5), wongames decimal(5))

insert into #Inwon
select #Inallgames.playerid, count(#Inallgames.playerid) as count
from #Inallgames
where #Inallgames.playerid <> @PlayerID
and #Inallgames.result = 1
group by #Inallgames.playerid
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.wongame, #Inallwon.allgames, 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 #Influenceallgames from #Inallwon

create table #InfluencePlayerID (playerid decimal(5))
insert #InfluencePlayerID values (@PlayerID)

create table #Influence (Playerid decimal(5), Allgames decimal (5), InfluenceValue float (5))

insert into #Influence
select #InfluencePlayerID.playerid, #Influenceallgames.allgames, #InfluenceValue.influencevalue
from #InfluencePlayerID, #Influenceallgames, #InfluenceValue

select *
from #influence

loop
GO
Nov 7 '06 #1
0 1144

Sign in to post your reply or Sign up for a free account.

Similar topics

4
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...
10
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...
2
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...
5
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...
5
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...
3
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...
4
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...
3
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...
5
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...
3
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
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.