Traps & Trick QuestionsEasy

Why does `WHERE COUNT(*) > 5` error?

Seen at: Google · Uber · Stripe

A junior analyst writes:

SELECT customer_id, COUNT(*) AS orders
FROM orders
WHERE COUNT(*) > 5
GROUP BY customer_id;

It errors. Why, and what’s the fix?

Draft your answer

Saved to this browser only. Try it before you peek at the model answer.

Stuck? Peek at a hint

Reveals the model answer and the self-score rubric.

More traps & trick questions questions