Bird
0
0

Given the table orders with columns customer_id and order_amount, what does this query return?

medium📝 query result Q4 of 15
SQL - GROUP BY and HAVING
Given the table orders with columns customer_id and order_amount, what does this query return?

SELECT customer_id, SUM(order_amount) FROM orders GROUP BY customer_id;
AList of customers with individual order amounts
BTotal order amount for each customer
CSum of all order amounts without grouping
DNumber of orders per customer
Step-by-Step Solution
Solution:
  1. Step 1: Understand the query

    The query groups rows by customer_id and calculates the sum of order_amount for each group.
  2. Step 2: Interpret the result

    Each row in the result shows a customer and the total of their orders.
  3. Final Answer:

    Total order amount for each customer -> Option B
  4. Quick Check:

    SUM aggregates values per group [OK]
Quick Trick: SUM with GROUP BY aggregates per group [OK]
Common Mistakes:
MISTAKES
  • Thinking SUM returns individual order amounts
  • Ignoring GROUP BY effect
  • Confusing SUM with COUNT

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes