| Article: |
SQL Data Types | |
| Subject: | how do we find nth highest in SQL | |
| Date: | 2004-11-14 21:40:07 | |
| From: | Question&answer | |
|
Response to: how do we find nth highest in SQL
|
||
|
To find the nth highest salary as below
|
||
Showing messages 1 through 5 of 5.
-
how do we find nth highest in SQL
2004-12-11 08:16:41 RuchirAwadhawal [Reply | View]
Query for Nth Max (Highest)
select sal from emp t
where &n = (select count(sal)
from (select distinct sal from emp)
where t.sal<=sal);
<b>Query for Nth Min (Lowest)
select sal from emp t
where &n = (select count(sal)
from (select distinct sal from emp)
where t.sal>=sal);




select sal from emp t
where &n = (select count(sal)
from (select distinct sal from emp)
where t.sal<=sal);
<b>Query for Nth Min (Lowest)
select sal from emp t
where &n = (select count(sal)
from (select distinct sal from emp)
where t.sal>=sal);