Since I am looking for a job change and this is the question I’m being asked in all of my interviews, I am sharing this with everyone hoping this will help you guys.
The most common type of question is find out the 5th highest value, find out the 2nd highest value, and so on.
The solution for this question goes like this, I am going to fetch 5th highest salary for an employee.
Select top 1 FirstName, Salary From Employees Where Salary Not In (Select Distinct Top 4 Salary From Employees order by Salary desc) order by Salary desc
Enjoy and have fun 🙂