|
I have the following data in a sql server 2005 table:
I want to update the win & loss columns so that each team has results compared to all other scores that week, so team1 would show 2 wins, 2 losses, team2 would have 3 wins, 1 loss, etc. Ever week the scores would be inputted and I want the wins and losses calculated. How do I go about this? It is a small database.
(comments are locked)
|
|
(I believe this will do what you want as long as there are no ties.)
Each week, run the procedure for that week #. Thanks for the replies. Both worked well, but I did not take ties into consideration when I posted my question. Option 2 works best for my needs. Thanks for the help.
Dec 07 '09 at 11:49 AM
user-697
(comments are locked)
|
|
A pair of reverse sorted RANK() functions should do the trick: Nice solution. I was concerned this wouldn't work for ties, but it's actually pretty good. If ties are possible, you could just add a column. I edited my answer to show an example.
Dec 06 '09 at 07:34 PM
Tom Staab
(comments are locked)
|


I think you need some more information about what will be entered. How do you go from 0-0 to 2-2?
also, how do you change weeks? Update the column or add a new row?