Tuesday, 18 April 2017

How to Find the 3rd or Nth Highest Salary in a Table via SubQuery




select min(Emp_sal) from Employee_Test where emp_sal in (select top 3 emp_sal from Employee_Test order by emp_sal desc)

OR

select min(emp_sal) from (select top 3 emp_sal from Employee_Test order by emp_sal desc) a 

No comments:

Post a Comment