How to find the nth highest salary in SQL ?

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
How to find the nth highest salary in SQL ?

Published on 16-Dec-2021 16:52:22

You may also like this!