To find nth highest salary use below code.

SELECT * FROM emp employee1 WHERE n = (SELECT COUNT(DISTINCT (employee2.salary) FROM emp employee2 WHERE employee2.salary >= employee1.salary))

use find 2th highest salary put only 2 on the place of n on the above query.
the query will become

SELECT  * FROM emp employee1 WHERE 2 = (SELECT COUNT(DISTINCT (employee2.salary) FROM emp employee2 WHERE employee2.salary >= employee1.salary))

for 3,4,5 ……, put exact number on the place of n on the above query.

eXTReMe Tracker