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 regions with the total sales amount per region.
BA list of all sales amounts without grouping.
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 aggregate functions

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

    The result shows each region once with the total sales amount summed from all rows in that region.
  3. Final Answer:

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

    GROUP BY + SUM() = totals per group [OK]
Quick Trick: GROUP BY with SUM() gives totals per group [OK]
Common Mistakes:
MISTAKES
  • Expecting all rows without grouping
  • Thinking SUM() causes error with GROUP BY
  • Confusing grouping with sorting

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes