Quick revision
The short answer
I would keep short SQL exercises but retire the classic Nth-highest-salary question as a standalone test, because it is so widely memorized that it mostly measures preparation. In its place I would use realistic, unseen schemas with built-in ambiguity, a shared rubric and calibrated interviewers, rotating question pools, and a round matched to what the job actually needs. Then I would check predictive value by comparing interview scores with later performance and ramp-up data, and watch for adverse impact on groups of candidates.
What to remember
In this answer, we treated the interview loop as a measurement system. The Nth highest salary question tests window functions, ties and NULLs quickly, but it is so widely memorized that on its own it measures preparation more than skill. We would keep short SQL exercises with realistic, unseen schemas and deliberate ambiguity, follow them with a performance discussion for senior roles, calibrate interviewers with shared rubrics and sample answers, rotate question pools against leaks, measure predictive value against later performance and ramp-up data while watching for adverse impact, and match each round to what the job really needs.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
I would keep short SQL exercises but retire the classic Nth-highest-salary question as a standalone test, because it is so widely memorized that it mostly measures preparation. In its place I would use realistic, unseen schemas with built-in ambiguity, a shared rubric and calibrated interviewers, rotating question pools, and a round matched to what the job actually needs. Then I would check predictive value by comparing interview scores with later performance and ramp-up data, and watch for adverse impact on groups of candidates.
Why this question is asked
When one leader owns the interview process for several hundred hires a year, every question in the loop is a decision repeated hundreds of times. A question that measures the wrong thing costs good hires we turned away and poor hires we accepted, and nobody notices because the cost is spread thin. Interviewers ask this leadership question to see whether we think of interviews as a measurement system that can be designed and tested, not a tradition. In this answer, we will look at what the classic question actually measures, design a better exercise, make scoring consistent across interviewers, protect the questions from leaking, measure whether the round predicts performance, and match the round to the job.
1What the Classic Question Actually Measures
The Nth highest salary question is not a bad question on its content. In five minutes it touches window functions, the difference between ROW_NUMBER, RANK and DENSE_RANK, tie handling, NULL ordering, and the difference between no rows and one row with NULL. A candidate who reasons through those points from first principles shows real skill.
The trouble is that it has been the standard question for decades, and it is on every preparation site with a model answer. So when a candidate writes a perfect DENSE_RANK solution in two minutes, we cannot tell whether they understand it or remember it. In measurement terms, the question has lost much of its signal: the score now mixes skill with preparation, and preparation is not what we are hiring for. A useful test for any question is to ask whether a strong engineer who has never seen it would do as well as a weak one who has memorized it. For this question the answer is often no.
2Designing a Better SQL Exercise
I would keep SQL exercises, because many backend roles need SQL every day, but change their shape. We give an unseen, realistic schema, for example orders, refunds and customers in different time zones, and a business question with deliberate ambiguity: ties, NULLs, a refund that arrives after month end, a customer who moved country. The candidate must state their assumptions before writing the query. That is what the real job looks like: the requirement is never as clean as the interview question.
For senior roles, we follow the query with a discussion: how it behaves on 200 million orders, which index helps, how we would check the plan, and how we would test the tie case. That part is very hard to memorize and separates people who have run SQL in production from those who have only practised puzzles.
3Making Scores Consistent Across Interviewers
With hundreds of hires and dozens of interviewers, the biggest source of noise is often the interviewer, not the candidate. One person passes anyone who reaches a working query; another fails anyone who forgets NULLS LAST. So each exercise ships with a rubric that names what we look for at each level, and sample answers at those levels. New interviewers shadow, then reverse-shadow, and we calibrate regularly by having several interviewers score the same recorded or written answer and discussing the differences.
| Level | What we see |
|---|---|
| Strong | states assumptions, handles ties and NULLs, explains plan and index |
| Solid | correct query, handles ties when prompted, reasonable index idea |
| Weak | query works on clean data only, misses ambiguity |
| Not yet | cannot produce a working query with hints |
Notice that the rubric rewards stated assumptions and reasoning, not only the final query. Two candidates with the same query can deserve different scores if one noticed the ties and the other got lucky.
4Protecting the Questions From Leaking
Any question we use hundreds of times will leak; candidates share them, and some sites collect them. So we keep a pool of exercises per round and rotate them, retire the oldest each quarter, and make variants of the same exercise with different schemas and twists. A leaked variant then helps one candidate a little rather than everyone a lot.
We also watch for signs of a leak. If the pass rate of one question rises sharply over a few weeks while others stay flat, if solve times drop to a fraction of the usual, or if candidates write answers that match each other word for word, including the same variable names, the question has probably leaked. Searching for the exercise text on public sites now and then is a cheap check too. When we see it, we retire the variant.
5Checking That the Round Predicts Performance
The real test of an interview round is whether its scores predict how people do in the job. With several hundred hires a year we have enough data to check. For each hire, we compare the SQL round score with later outcomes: performance ratings at 6 and 12 months, ramp-up time to the first significant change shipped, and manager feedback on data-related work. If high scorers do no better than low scorers, the round is not measuring what we need.
- Collect round scores for hiresplus later ratings and ramp-up time
- Do higher scores go with better outcomes?YesKeep the round, refine the rubricNoRedesign or drop the round
- Pass rate gap between groups?below 80 percent of the top groupYesInvestigate questions and interviewersNoKeep monitoring
- Publish results to interviewerswhat changed and why
4 steps in order. Play them, or step through them one at a time.
There is a statistical catch: we only see outcomes for people we hired, who all scored reasonably well, so the relationship looks weaker than it really is. That is called restriction of range, and it means we look at trends rather than expecting strong correlations. We must also check adverse impact: whether a round's pass rate for one group of candidates is much lower than for others. A common rule of thumb flags concern when a group's pass rate is below 80 percent of the highest group's rate. A gap like that needs investigation, because it may mean the round measures background or familiarity rather than the skill.
6Matching the Round to the Job
Finally, one SQL round does not fit every role. A backend engineer on a data-heavy service needs to write and tune complex queries, so a deep round with a performance discussion makes sense. Many other roles mostly need to read and review SQL: understanding what a query from an ORM does, spotting an N+1 pattern or a missing index in a pull request. For them, a short review exercise, "here is a query and its plan, what is wrong?", predicts more than writing a puzzle from scratch. Matching the round to the job also respects the candidate's time, which matters for our reputation at this scale.
7Follow-up questions
How would you detect that a question has leaked?
Track pass rates and solve times per question over time, and compare them with other questions in the same round. A sudden rise in pass rate, much faster solutions, or identical answers across unrelated candidates are strong signs. Periodic searches for the exercise text on public sites help too, and we retire the variant as soon as we see it.
Isn't an unseen, ambiguous exercise unfair to nervous candidates?
It can be if we spring the ambiguity as a trap. We tell candidates up front that the problem is deliberately underspecified and that asking questions is part of the exercise, and the rubric rewards it. That makes it fairer than a memorization test, which favours people with more time to prepare.
What if the data shows the SQL round predicts nothing?
First check the data quality and the restriction of range effect. If the round still shows no relationship, we either change it to match the work better or remove it and give the time to a round that does predict performance.
8Conclusion
In this answer, we treated the interview loop as a measurement system. The Nth highest salary question tests window functions, ties and NULLs quickly, but it is so widely memorized that on its own it measures preparation more than skill. We would keep short SQL exercises with realistic, unseen schemas and deliberate ambiguity, follow them with a performance discussion for senior roles, calibrate interviewers with shared rubrics and sample answers, rotate question pools against leaks, measure predictive value against later performance and ramp-up data while watching for adverse impact, and match each round to what the job really needs.
Open with
I would not keep it as a standalone question. Its content is fine: it tests window functions, ties, NULL ordering and the difference between no row and a NULL row in a few minutes.
Then, if they want more
But it is one of the most memorized questions there is, so a fast perfect answer mostly tells me the candidate prepared. I would keep SQL exercises but use realistic schemas the candidate has not seen, with deliberate ambiguity like ties, NULLs and time zones, and ask them to state assumptions before they write anything.
For senior roles I would follow up with how the query behaves at scale, which index helps and how they would test it. At several hundred hires a year, interviewer noise is a big problem, so every exercise gets a rubric with sample answers, and we calibrate by having interviewers score the same answers.
We rotate a pool of variants and watch pass rates and solve times to detect leaks. Then I would check the round actually works: compare scores with performance ratings and ramp-up time after six and twelve months, keeping in mind we only see people we hired, and check pass rates by group for adverse impact.
And I would match the round to the job: many roles need to read and review SQL more than write puzzles, so a review exercise fits them better.
About this answer
- Last updated
- 12 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- PostgreSQL documentation, The SQL Language
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with ""Find the Nth highest salary" has been a standard SQL interview question for decades. As...": https://scrivio-interview-library.netlify.app/databases/sql-coding-problems/895fd00fbe/