Bird
0
0

Given the table sales with columns region and amount, what will this query return?

medium📝 query result Q13 of 15
SQL - GROUP BY and HAVING

Given the table sales with columns region and amount, what will this query return?

SELECT region, SUM(amount) FROM sales GROUP BY region HAVING SUM(amount) > 1000;
AAll regions with total sales greater than 1000
BAll regions with total sales less than or equal to 1000
CAll sales records with amount greater than 1000
DSyntax error due to HAVING clause
Step-by-Step Solution
Solution:
  1. Step 1: Group sales by region and sum amounts

    The query groups rows by region and calculates total amount per region.
  2. Step 2: Filter groups with total sales > 1000

    The HAVING clause keeps only regions where the sum is greater than 1000.
  3. Final Answer:

    All regions with total sales greater than 1000 -> Option A
  4. Quick Check:

    HAVING filters groups by aggregate sum [OK]
Quick Trick: HAVING filters groups by aggregate results [OK]
Common Mistakes:
MISTAKES
  • Thinking HAVING filters individual rows
  • Confusing SUM(amount) with amount column
  • Assuming syntax error with HAVING

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes