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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2001-11-20 : 09:12:05
|
| Chris writes "I'm attempting to calculate a score for each person in a table. To calculate the score for each person I use the Sum() function inside a correlated subquery. I then want to order the results by the score.I need the Sum() function to be in a subquery because it pulls information from 3 tables.The score calculation works perfectly, but this query below orders the scores in the same order the user appears in the table, i.e. they are not being ranked by their score.The query is as follows:SELECT TOP 10 (SELECT SUM (score calculation)) as Score, usernameFROM tableMembersORDER BY ScoreI did not include the entire select statement from the score calculation because it is very long and it works, so I don't think it is relevant, however it is a correlated subquery as it uses the username to identify which rows to calculate the score on.Shouldn't this work? Any help would be appreciated.Chris Brubaker" |
|
|
|
|
|