Oracle SQL Question:
Download Questions PDF

How to find out nth highest salary from emp table?

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 Interview Questions And Answers PDF

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?