Our problem is to find 2nd highest salary from the employee table using mysql .
First Method: We will sort the salaries in descending order and will limit the solution by one.
SELECT name, salary FROM employees ORDER BY salary DESC LIMIT 1 , 1
But this will not give all the results if there are two employees whose salaries are same(second highest).
Above solution will return Steve only.
So here is the alternative way using nested subquery:
SELECT name, salary FROM EMPLOYEE WHERE salary = (SELECT MAX(salary) FROM EMPLOYEE WHERE salary < (SELECT MAX(salary) FROM EMPLOYEE))