Sign In/My Account
|
View Cart
O'Reilly Home
Community
Books & Videos
Safari Books Online
Conferences
Training
School of Technology
About
Search
Search Tips
Article:
SQL Data Types
Subject:
how do we find nth highest in SQL
Date:
2005-09-25 23:55:04
From:
lalitpant
Response to:
how do we find nth highest in SQL
Showing messages 1 through 2 of 2.
how do we find nth highest in SQL
2005-10-17 23:28:21 Apurva_Sharma [
View
]
Hi,
Solution to your query.Plz follow steps.
Steps
SQL> SET Verify OFF;
SQL> SELECT min(sal)
FROM (SELECT sal
FROM emp
order by sal desc)
WHERE rownum<(&nth_heighest+1);
how do we find nth highest in SQL
2009-10-13 12:05:05 Sandip D [
View
]
HI Apporva,
I think this is also correct,
but can't u try this out, which is more simple :-
SELECT DISTINCT (a.sal) FROM EMP A WHERE &N = (SELECT COUNT (DISTINCT (b.sal)) FROM EMP B WHERE a.sal<=b.sal);
Enter value for n: 2
SAL
---------
3700
Solution to your query.Plz follow steps.
Steps
SQL> SET Verify OFF;
SQL> SELECT min(sal)
FROM (SELECT sal
FROM emp
order by sal desc)
WHERE rownum<(&nth_heighest+1);