Oracle SQL Question:

How to find out nth highest salary from emp table?

Tweet Share WhatsApp

Answer:

SELECT DISTINCT (a.sal) FROM EMP A WHERE &N = (SELECT COUNT (DISTINCT (b.sal)) FROM EMP B WHERE a.sal<=b.sal);
For Eg:-
Enter value for n: 2
SAL
---------
3700

Download SQL Oracle PDF Read All 16 SQL Oracle Questions
Previous QuestionNext Question
Explain Which is more faster - IN or EXISTS?Explain What should be the return type for a cursor variable. Can we use a scalar data type as return type?