Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
safa
Starting Member
2 Posts |
Posted - 2009-11-10 : 04:55:42
|
| HiIm having some difficulty getting percentages of results that happened after certain results sports:% Of Losses, Draws and wins for teams that beat TeamA on SeasonA a week beforeMy Sports result table:]ID | League | Season | Week | HTeam | ATeam | Hscore | AScoreGetting the teams and the week that they Beat teamA at Season A is easy enoughI Now need to get their results the next week into %Won % Draws %WinsSuppose I also need the best way this could be done ie. SProcs, Views etc..Cheers |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-11-10 : 05:03:17
|
Give sample data and wanted output please. No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
safa
Starting Member
2 Posts |
Posted - 2009-11-10 : 08:10:13
|
| Hi WebfredHere's a few lines from Sports_Results tableID LeagueID Season [Week] Date HTID ATID HScore AScore------------------------------------------------------------------------------------1 1 1994 1 1993-08-14 1 10 0 32 1 1994 1 1993-08-14 2 29 4 13 1 1994 1 1993-08-14 9 5 1 24 1 1994 1 1993-08-14 19 32 2 05 1 1994 1 1993-08-14 20 17 1 16 1 1994 1 1993-08-14 23 37 0 17 1 1994 1 1993-08-14 27 16 0 38 1 1994 1 1993-08-14 31 36 3 19 1 1994 1 1993-08-14 33 13 0 210 1 1994 1 1993-08-14 40 42 0 211 1 1994 1 1993-08-15 25 21 0 2I run this query to get all the teams that beat team_21 at season_2002Set @Champ=21Set @SSN=2002Select Count(*) As Times, [Week], (Case When HTID=@Champ Then ATID When ATID=@Champ then HTID END) As CID From Sports_Results Where ((HTID=@Champ and HScore>AScore) Or (ATID=@Champ and HScore<AScore)) And Season=@SSN And [Week]<38Group By HTID, ATID, [Week]Order By [Week]Result:Times Week CID-------------------1 5 241 10 61 12 191 14 11 15 91 16 401 31 221 33 191 35 1I got 9 teams that beat team_21 in season_2002I need to know the next week's results for those teams that beat team_21 so I need Team_24 at week 6, Team_6 at week_11, Team_19 at week_13, etc..Take the number of teams that won, drew and lost (After beating team_21) and divide each result by 99/Won, 9/drew, 9/LostSo the result needs to be: Of all the teams that beat team_21 at season_2002 %won, %drew and %Lost their next game ..Thanks for the help |
 |
|
|
|
|
|
|
|