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 - 2005-11-22 : 07:39:49
|
| parry writes "hi guysHow do I write query that gives top 100 ppl by their salary (highest to lowest) from each group. Each group has unique number and each group has several member let say more than 300, and there are about 125 groups. There is only table. for examplegrid mem_id sal001 1258 5987001 2574 8754025 8574 9857Thanks in advance" |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2005-11-22 : 07:47:25
|
| select *from tbl t1where t1.id in (select top 100 t2.id from tbl t2 where t1.grp = t2.grp order by t2.salary desc)==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|
|