December 24, 2025
One SQL Question That Fails 70% of Candidates
A deceptively simple SQL question that exposes weak fundamentals — and how to answer it the way interviewers expect

By Ankur Gupta
1 min read
You can read the full article using this friend link.
Why This SQL Question Is So Dangerous
Most SQL interview failures don't happen because the problem is hard. They happen because the problem looks easy.
This is one of those questions.
Interviewers ask it to test whether you truly understand how SQL works internally, not whether you've memorized syntax.
And yet, nearly 70% of candidates get it wrong.
The Question That Fails Most Candidates
What is the difference between
WHEREandHAVING? When should you use each?
Sounds basic, right?
That's why it's so effective.
The Common (Wrong) Answer
Most candidates say something like:
"
WHEREfilters rows andHAVINGfilters groups."
While this is technically true, it's not enough.
Interviewers aren't looking for definitions. They're looking for execution-order understanding.
What Interviewers Are Actually Testing
This question checks whether you understand:
- SQL query execution order
- Aggregations vs row-level filtering
- Why some queries fail with errors
- How databases process data internally
If you miss this, it signals shallow SQL knowledge.
The Correct Way to Think About It
Let's break it down properly.
WHERE
- Filters rows
- Executes before aggregation
- Cannot be used with aggregate results
HAVING
- Filters aggregated data
- Executes after
GROUP BY - Used with aggregate functions like
COUNT,SUM,AVG
But the key insight is when they run, not just what they do.
The SQL Execution Order (This Is the Secret)
SQL does not execute in the order you write it.
The simplified execution order is:
- FROM
- WHERE
- GROUP BY
- HAVING
- SELECT
- ORDER BY
This is the part most candidates don't know.
Why Candidates Fail in Interviews
Consider this mistake:
Filtering aggregated results using WHERE.
This leads to:
- SQL errors
- Incorrect results
- Interview rejection
Interviewers immediately know the candidate doesn't understand aggregation.
How Strong Candidates Answer This Question
A strong interview answer sounds like this:
"
WHEREfilters rows before aggregation, whileHAVINGfilters aggregated results afterGROUP BY. Since aggregate functions run after grouping, conditions on aggregates must be applied usingHAVING."
This answer shows:
- Conceptual clarity
- Execution-order understanding
- Confidence
A Simple Rule to Remember
If the condition involves:
- Raw columns → use
WHERE - Aggregated values → use
HAVING
This rule alone can save you in interviews.
Why Interviewers Love This Question
Because it:
- Looks easy
- Has a high failure rate
- Separates real understanding from memorization
- Predicts how well you'll write production SQL
That's why it keeps coming back in interviews.
Final Thoughts
SQL interviews don't fail candidates on complex joins or window functions.
They fail candidates on fundamentals they assume they already know.
If you understand when SQL filters data, not just how, you're already ahead of most candidates.