Write SQL query to find second highest salary?

How to find the employee whose salary is second highest?


For example, in above table, “Hardik” has the second highest salary as 55000.

Below is simple query to find the employee whose salary is highest.

SELECT name, MAX(salary) as salary FROM employee;

We can use above query to find the second largest salary by nesting it.

SELECT name, MAX(salary) AS salary FROM employee 
WHERE salary < (SELECT MAX(salary) FROM employee);

Author: Mahesh

Technical Lead with 10 plus years of experience in developing web applications using Java/J2EE and web technologies. Strong in design and integration problem solving skills. Ability to learn, unlearn and relearn with strong written and verbal communications.