Bird
0
0

Given the table sales with columns region and amount, what is the output of this query?

medium📝 query result Q13 of 15
SQL - GROUP BY and HAVING
Given the table sales with columns region and amount, what is the output of this query?
SELECT region, SUM(amount) FROM sales GROUP BY region;
AA list of all sales amounts without grouping.
BA list of regions with the total sales amount for each region.
CAn error because SUM() cannot be used with GROUP BY.
DA list of regions sorted by amount.
Step-by-Step Solution
Solution:
  1. Step 1: Understand GROUP BY with SUM()

    The query groups rows by region and sums the amount for each group.
  2. Step 2: Predict output format

    The output shows each region once with the total amount of sales in that region.
  3. Final Answer:

    A list of regions with the total sales amount for each region. -> Option B
  4. Quick Check:

    GROUP BY + SUM() = grouped sums [OK]
Quick Trick: GROUP BY + SUM() gives totals per group [OK]
Common Mistakes:
MISTAKES
  • Thinking SUM() can't be used with GROUP BY
  • Expecting ungrouped list
  • Confusing sorting with grouping

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes