2nd Highest Salary

4pts
FAANG

Problem Statement

In payroll analysis, identifying the runner-up in salary tiers is a common task. You are tasked with finding the second highest distinct salary from the Employee table.

Write an SQL query to report the second highest salary from the Employee table. If there is no second highest salary, the query should report null.

Rules:

  • The result column should be named SecondHighestSalary.
  • If multiple employees share the highest salary, the second highest must be the next distinct value below them.
  • Return a single value (or null).
Tests your understanding of
Basic SQL, Subquery, LIMIT, OFFSET and NULL handling

Input Tables

employee
id(INTEGER)salary(INTEGER)
1100
2200
3300
4300
5250
650

Expected Output

SecondHighestSalary(INTEGER)
250

Tags

MediumBasic SQLSubqueryLIMITOFFSETNULL handling
10-15 min
38%

Hints