Bird
0
0

Find the mistake in this query:

medium📝 Debug Q7 of 15
SQL - GROUP BY and HAVING
Find the mistake in this query:
SELECT product, SUM(quantity) FROM sales HAVING SUM(quantity) > 100;
AHAVING cannot be used without WHERE
BNo mistake, query is valid
CSUM(quantity) cannot be used in HAVING
DMissing GROUP BY clause when using HAVING
Step-by-Step Solution
Solution:
  1. Step 1: HAVING filters groups after GROUP BY

    HAVING requires groups to filter, so GROUP BY must be present.
  2. Step 2: Query lacks GROUP BY, so HAVING causes error

    Without GROUP BY, HAVING cannot filter groups.
  3. Final Answer:

    Missing GROUP BY clause when using HAVING -> Option D
  4. Quick Check:

    HAVING needs GROUP BY to filter groups [OK]
Quick Trick: HAVING requires GROUP BY clause [OK]
Common Mistakes:
MISTAKES
  • Using HAVING without GROUP BY
  • Thinking HAVING needs WHERE
  • Misusing aggregate in HAVING

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes