Find the nth highest salary in mysql without limit


How to get the third highest salary in MySQL

Get the nth highest salary in mysql without limit by (n) ,Here WHERE ( n ) you can enter any number to return that highest salary.

How to get the highest salary in MySQL without limit ?

SELECT * FROM `employee` a WHERE (1) = (SELECT count(salary) from employee b where a.salary<=b.salary);

    id  name    salary  
------  ------  --------
     4  Vishal      7000

How to find 2nd highest salary in MySQL ?

SELECT * FROM `employee` a WHERE (2) = (SELECT COUNT(salary) FROM employee b WHERE a.salary<=b.salary);

    id  name    salary  
------  ------  --------
     3  Rahul       6000

How to get 3rd highest salary in MySQL ?

SELECT * FROM `employee` a WHERE (3) = (SELECT COUNT(salary) FROM employee b WHERE a.salary<=b.salary);

    id  name    salary  
------  ------  --------
     1  Ramesh      5000

How to find 4th highest salary in MySQL ?

SELECT * FROM `employee` a WHERE (4) = (SELECT COUNT(salary) FROM employee b WHERE a.salary<=b.salary);

    id  name    salary  
------  ------  --------
     2  Ashish      4000

How to find 5th highest salary in MySQL ?

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
how to find duplicate records in MySQL query
How to use second index forcefully in MySQL
How to get total number of rows in MySQL table with and without count
Difference between where and having clauses