โ† SQL & Databases
#1 most askedVery commonMediumSubqueries

Second-Highest Salary

New to Subqueries? Learn it from scratch first
Subqueries & CTEs โ†’
๐Ÿข Asked in real interviews
No reports yet. Were you asked this? Be the first to say where.
I was asked this

Table employees(id, name, department_id, manager_id, salary, hire_date, email).

Return the second-highest distinct salary as one column named second_highest. If there isn't one, return NULL.

๐Ÿงช Practice

Write the query, then press Run tests to compare your rows with the expected result.

SQL
SELECT *
FROM employees;

Output appears here. Press Run or Ctrl/โŒ˜ + Enter.

Try it first. Struggling for a few minutes is how it sticks.