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 - 2003-04-22 : 07:30:58
|
yousef writes "i have this dataid point---------------------------------------------a 100b 100c 90d 90e 80f 70g 60. .. .. .and my out put isid point---------------------------------------------a 100b 100c 90d 90e 80i use this code : select top 3 with ties id,point from tbPointorder by point descbut i get id point---------------------------------------------a 100b 100c 90can someone help me?" |
|
mohdowais
Sheikh of Yak Knowledge
1456 Posts |
Posted - 2003-04-22 : 09:28:34
|
Yousef: What this query returns is logically correct, it is returning the top 3 combinations of id and point. You might want to use a sub-query to return the top three points like this:SELECT id, point FROM tableName WHERE point IN(SELECT DISTINCT TOP 3 point from tableName order by point DESC)OS |
 |
|
|
|
|