Get the second highest value in a MySQL table

Question:
 Select name of the persons who are getting second highest salary 
Salary Table
name salary
Alex 50
Kane 45
Root 50
Smith 45
Joe 20
John 38

Answer:

1
2
3
SELECT name
FROM Salary
WHERE salary = (SELECT MAX(salary) FROM Salary WHERE salary < (SELECT MAX(salary) FROM Salary));

Comments

Popular Posts