Thursday, 9 February 2017

How would I find the second largest salary from the employee table?

Simple Approach ::
SELECT max(salary)
FROM emptable
WHERE salary < (SELECT max(salary)
                FROM emptable);
Alternate Approach ::
SELECT sal
FROM emp
ORDER BY sal DESC
LIMIT 1, 1;

No comments:

Post a Comment