Second and Third Highest Salary using mysql
It is very easy to find second highest salary
SELECT *
FROM emp
WHERE salary =(SELECT salary
FROM emp
GROUP BY salary
ORDER BY salary DESC
LIMIT 1 , 1)
Third highest salary you can find following ways
SELECT *
FROM emp
WHERE salary =(SELECT salary
FROM emp
GROUP BY salary
ORDER BY salary DESC
LIMIT 2 , 1)
SELECT *
FROM emp
WHERE salary =(SELECT salary
FROM emp
GROUP BY salary
ORDER BY salary DESC
LIMIT 1 , 1)
Third highest salary you can find following ways
SELECT *
FROM emp
WHERE salary =(SELECT salary
FROM emp
GROUP BY salary
ORDER BY salary DESC
LIMIT 2 , 1)