Monday, March 28, 2011

Get the top 5th salary of all employees

SELECT SALARY FROM


(SELECT VAL1, RANK() OVER (ORDER BY VAL1 DESC) R from TEMPX)


WHERE R=5;


OR


SELECT DISTINCT (a.sal) FROM EMP A WHERE 5= (SELECT COUNT (DISTINCT (b.sal)) FROM EMP B WHERE a.sal<=b.sal);


No comments: