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 |
|
taylo
Yak Posting Veteran
82 Posts |
Posted - 2004-07-08 : 15:34:10
|
| GreetingsI am trying to do this in a Stroed Proc:Select @points = Sum(Top 3 Points) from MyScores where UserID = @userid order by points descBut it throws an error. I am not sure how to tackle this.A user could have 10 point entries and i only want the sum of the Top 3. Does anyone know how to do this without using a temp table?Thanks.....Rob |
|
|
LarsG
Constraint Violating Yak Guru
284 Posts |
Posted - 2004-07-08 : 15:38:29
|
| [code]Select @points = Sum(points)from ( select Top 3 Points from MyScores where UserID = @userid order by points desc ) dt[/code] |
 |
|
|
taylo
Yak Posting Veteran
82 Posts |
Posted - 2004-07-09 : 07:39:08
|
| Thank you!Rob |
 |
|
|
|
|
|