Saturday, August 27, 2011

How to find nth highest salary from a table?


Code
  1. EMPNO ENAME SAL
  2. 1         A         5000
  3. 2         B         2000
  4. 3         C         10000
  5.  
  6. SELECT MIN(SAL) FROM (SELECT * FROM EMP ORDER BY SAL DESC)
  7. WHERE ROWNUM <=2

    Same as nth highest query we need to put that number instead of 2.

No comments:

Post a Comment