Quick interview answer
Use DENSE_RANK() in a subquery, or the classic MAX with a nested exclusion.
Detailed explanation
Window functions handle duplicates correctly and scale to Nth highest. Be ready to explain the difference between RANK, DENSE_RANK and ROW_NUMBER.
sql
1SELECT salary2FROM (3 SELECT salary, DENSE_RANK() OVER (ORDER BY salary DESC) AS rnk4 FROM employees5) t6WHERE rnk = 2;Real-world example
Data validation tests comparing UI leaderboards against the database.
Interview tip
Offer the Nth-highest generalisation before they ask for it.