Second Highest Salary Problem & Solution

Write a SQL query to get the second highest salary from the Employee table.

See the second highest salary problem on LeetCode.

SQL Solution

SELECT IFNULL(
  (SELECT DISTINCT(Salary)
   FROM Employee
   ORDER BY Salary DESC
   LIMIT 1
   OFFSET 1),
  NULL) AS SecondHighestSalary;

Are you looking for a job?