Skip to content

Latest commit

 

History

History
16 lines (14 loc) · 321 Bytes

File metadata and controls

16 lines (14 loc) · 321 Bytes

176. Second Highest Salary

Select the second highest distinct salary from the employee table.
We utilize IFNULL to return NULL if the nth highest salary doesn't exist.

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