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 |
|
esambath
Yak Posting Veteran
89 Posts |
Posted - 2010-02-03 : 08:34:28
|
| hi,i have one table salaryempid empname salary1 A 230002 B 300003 C 22000get record in 2nd highest salaryoutput 1 A 23000kindly help this one |
|
|
Lumbago
Norsk Yak Master
3271 Posts |
Posted - 2010-02-03 : 08:36:37
|
| SELECT empid, empname, salaryFROM tableWHERE (RANK() OVER PARTITION BY salary DESC)) = 2...I'm not too good at this on the fly but I think it should work...- LumbagoIf the facts don't fit the theory, change the facts. Albert Einstein |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-02-03 : 11:07:28
|
quote: Originally posted by Lumbago SELECT empid, empname, salaryFROM tableWHERE (DENSE_RANK() OVER PARTITION BY salary DESC)) = 2...I'm not too good at this on the fly but I think it should work...- LumbagoIf the facts don't fit the theory, change the facts. Albert Einstein
might have a problem when you've two records with same highest salary so I would put my bet on small modification above |
 |
|
|
|
|
|