Run the below SQL query to generate any level of highest value to calculate:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
SELECT MAX(sal) AS salary FROM emp WHERE deptno = 10 and level = 2 /* change this value to find nth maximum salary */ CONNECT BY prior sal > sal GROUP BY level ORDER BY level |
In the above query statement, just change the Level = 2, 3,4…etc to find the nth position of maximum value.
Thank You
Awesome Short Tricks….
Whats’s wrong with keeping it simple?
SELECT
MAX(sal)
FROM
emp
WHERE
deptno = 10 and
sal<(select max(sal) from emp where deptno=10)