Friday, May 3, 2019

How to find out nth highest salary of an employee




SELECT Salary, id
FROM
(
SELECT Salary,id,DENSE_RANK() OVER(ORDER BY Salary ASC) Row_numbr from emp1
) tbl
WHERE Row_numbr=n

In the above example if you want to find out the 3rd higest salary of an employee, then pass 3 in place of n.

No comments:

Post a Comment