Bird
0
0

Given the table sales with columns region and amount, what is the result 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 result 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 average sales amount.
CAn error because SUM() cannot be used with GROUP BY.
DA list of regions with the total sales amount for each region.
Step-by-Step Solution
Solution:
  1. Step 1: Understand the query components

    The query groups rows by region and calculates the sum of amount for each group.
  2. Step 2: Determine the output

    The output will show each region once with the total sales amount summed up.
  3. Final Answer:

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

    GROUP BY region + SUM(amount) = total per region [OK]
Quick Trick: SUM with GROUP BY gives total per group, not average or error [OK]
Common Mistakes:
MISTAKES
  • Confusing SUM with AVG
  • Expecting no grouping effect
  • Thinking SUM causes error with GROUP BY

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes