Runner-Up Salary
Problem
**[Widely asked at FAANG companies]**
Find the second highest distinct salary in the company.
If no second-highest exists (e.g., all employees earn the same salary),
return `NULL`.
Return a single value in a column named `second_salary`.
Tables
Example rows — the live problem includes the full dataset.
employees
| employee_id | name | salary |
|---|
Expected output
Your answer should return 1 row with the columns second_salary.
Starter code (SQL)
SELECT *
FROM employees;Solve this SQL question free
Write SQL and run it instantly in your browser — even on your phone. No signup needed to try.
Solution & explanation
Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.
Sign up free to unlock