Pages

Showing posts with label maximum salary. Show all posts
Showing posts with label maximum salary. Show all posts

Monday, February 8, 2010

SQL SERVER – Find Nth Highest Salary of Employee – Query to Retrieve the Nth Maximum value

This question is quite a popular question and it is interesting that I have been receiving this question every other day. I have already answer this question here. “How to find Nth Highest Salary of Employee”.

How to get 1st, 2nd, 3rd, 4th, nth topmost salary from an Employee table

The following solution is for getting 5th highest salary from Employee table ,

SELECT TOP 1 salary
FROM (
SELECT DISTINCT TOP 5 salary
FROM employee
ORDER BY salary DESC) a
ORDER BY salary


If you want to retrieve a nth Maximum value then use nth value instead of 5 and enjoy!!!!!!!

Cheers