Wednesday 3 December 2014

Query to find Nth heighest salary from Employee Table

SELECT SAL FROM EMPLOYEE emp1 WHERE (

      SELECT COUNT(DISTINCT SAL) FROM EMPLOYEE  emp2

              WHERE emp2.SAL >=  emp1.SAL) = N

Here if N is 3 you can find 3rd highest salary ..

No comments:

Post a Comment