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 |
|
lax
Starting Member
1 Post |
Posted - 2004-05-26 : 10:19:46
|
| Sir,Can you please let me know the Query to retrieve the Nth Maximum or Minimum Row in a table Say fore xample I want to retrieve the 5th Maximum or Minimum SALARY in the Employee TABLE. Example : for N=2 it can be SELECT MAX(SALARY) FROM EMPLOYEE_SALARY WHERE SALARY < (SELECT MAX(SALARY) FROM EMPLOYEE_SALARY) how about for N > 2. |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
Merkin
Funky Drop Bear Fearing SQL Dude!
4970 Posts |
|
|
Merkin
Funky Drop Bear Fearing SQL Dude!
4970 Posts |
Posted - 2004-05-26 : 10:24:49
|
SNIPED Damian |
 |
|
|
gates_micro
Starting Member
29 Posts |
Posted - 2004-06-02 : 02:23:29
|
| declare @N intset @N = 2SELECT A.MARKS FROM ORDERTABLE A WHERE @N=(SELECT COUNT(MARKS)+1 FROM ORDERTABLE B WHERE B.MARKS>A.MARKS) ORDER BY A.MARKS DESC |
 |
|
|
|
|
|