How to get third largest salary or nth salary in Mysql

We are using Top keyword here to find out nth salary.


SELECT TOP 1 salary FROM (
SELECT TOP 3 salary
FROM employees
ORDER BY salary DESC) AS emp
ORDER BY salary ASC

You can replace 3 to any number to find nth salary.

Using Limit to find nth highest salary

You can replace n with the required highest salary.

SELECT DISTINCT(Salary) FROM table ORDER BY Salary DESC LIMIT n-1,1

Leave a Reply