How to find the nth highest salary in SQL ?

DBMSMySQLSQL

This is how we can find the nth highest salary in SQL SERVER using TOP keyword:

SELECT TOP 1 salary FROM ( SELECT DISTINCT TOP N salary FROM Employee ORDER BY salary DESC ) AS temp ORDER BY salary
This is how we can find the nth highest salary in MYSQL using LIMIT keyword:

SELECT salary FROM Employee ORDER BY salary DESC LIMIT N-1, 1
       

Advertisements

ads