sqlintermediate10 minutes

Find the Second Highest Salary

Return the second highest salary from an employees table.

Challenge prompt

Write a SQL query that returns the second highest salary from an employees table.

Guidance

  • Think about ordering salaries from highest to lowest.
  • You may need DISTINCT if duplicate salaries exist.
  • A subquery can help isolate the answer.

Hints

  • Try combining DISTINCT with ORDER BY.
  • LIMIT and OFFSET may help depending on SQL dialect.

Expected output

The query should return the second highest unique salary value.

Core concepts

subqueriessortingdistinct

Challenge a Friend

Send this duel to someone else and see if they can solve it.