Get the nth highest salary in mysql without limit by (n) ,Here WHERE ( n ) you can enter any number to return that highest salary.
SELECT * FROM `employee` a WHERE (1) = (SELECT count(salary) from employee b where a.salary<=b.salary);
id name salary ------ ------ -------- 4 Vishal 7000
SELECT * FROM `employee` a WHERE (2) = (SELECT COUNT(salary) FROM employee b WHERE a.salary<=b.salary);
id name salary ------ ------ -------- 3 Rahul 6000
SELECT * FROM `employee` a WHERE (3) = (SELECT COUNT(salary) FROM employee b WHERE a.salary<=b.salary);
id name salary ------ ------ -------- 1 Ramesh 5000
SELECT * FROM `employee` a WHERE (4) = (SELECT COUNT(salary) FROM employee b WHERE a.salary<=b.salary);
id name salary ------ ------ -------- 2 Ashish 4000
SELECT * FROM `employee` a WHERE (5) = (SELECT COUNT(salary) FROM employee b WHERE a.salary<=b.salary);
id name salary ------ ------ -------- 5 Harsh 3000
Related
How to find greater than average salary records in MySQL