Tuesday, January 20, 2009

SQL: Find nth highest salary

If you want to use nth highest salary, use the following query.

this query will find 6th highest salary



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

No comments:

Post a Comment