Thursday, 5 January 2012

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

No comments:

Post a Comment