Quick-fire SQL theory questions
Short "what is the difference between…" questions that open many SQL interviews; each is best answered with a one-line definition of both sides, the key difference, and when you would use each.
Why it matters
These questions take thirty seconds each but set the tone for the interview. A crisp answer shows you really understand the tool; a vague one makes the interviewer dig deeper. They are collected here so you can revise them in one place.
The idea
Use the same three-part shape every time. One: define both things in a sentence each. Two: state the difference that matters. Three: say when you would choose each, ideally with an example. Keep it under thirty seconds, then stop — let them ask for more. Open the follow-up questions below and answer each one out loud before showing the answer.
Penalty practice. You don't learn penalties by thinking about them; you take the same kick again and again until it is automatic, so it holds up under pressure.
A penalty is the same every time. Interviewers rephrase questions, so learn the idea behind each answer, not just the words.
How it works
- Define both sides: "WHERE filters rows; HAVING filters groups."
- Give the difference that matters: "WHERE runs before grouping, so it can't use aggregates."
- Say when to use each: "Row conditions in WHERE, aggregate conditions in HAVING."
- Offer a tiny example if it helps, then stop talking.
Key points
- Shape: define both, the key difference, when to use each.
- Keep it under thirty seconds, then stop.
- Use a tiny example from tables you know, like employees and orders.
- Revise the follow-up questions below out loud until each answer is automatic.
Common mistakes
- Rambling for two minutes on a thirty-second question.
- Giving only one side ("HAVING is for groups") without the contrast.
- Memorising words without the reason, then freezing when the question is rephrased.
Not true: For a quick theory question, a two-minute answer scores better than thirty seconds.
In fact: Thirty seconds is enough: define both things, give the key difference, say when to use each, then stop. A long answer hides the point.
In the interview
For any "what's the difference" question I give a one-line definition of each, the difference that matters in practice, and when I would choose each. For example: WHERE filters rows before grouping and can't use aggregates; HAVING filters groups after GROUP BY and can — so row conditions go in WHERE and aggregate conditions in HAVING.
Part of Unit 8: SQL interview problems, from easy to hard in the free SQL course.