How to get 2nd, 3rd, 4th, nth topmost salary from an Employee table.
we can get top salary in 2 ways
1)
select top 1 salary from2)
( select distinct top n salary from Employee order by salary desc ) a
order by Salary
select * from Employee e where n-1 =
(select count(Salary) from Employee f where e.EmpId <= f.EmpId) -- this query won't work for 1st highest salary
In the above query n = 2nd, 3rd ..... nth salary as per your requirement
No comments:
Post a Comment