How to get nth Highest salary of Employee in Department wise
select * from
(
select EmployeeName, DeptID, Sal, Rank()
over (Partition BY EmployeeName order by Sal DESC, DeptID DESC)
as Rank
from
Employee
) tmp
where Rank = @n
(
select EmployeeName, DeptID, Sal, Rank()
over (Partition BY EmployeeName order by Sal DESC, DeptID DESC)
as Rank
from
Employee
) tmp
where Rank = @n
Comments
Post a Comment