Problems / Customer Order Summary / Editorial
customers
orders
customer_id
COUNT(order_id)
order_id
SUM
AVG
COALESCE(..., 0)
total_amount
Using COUNT(order_id) instead of COUNT(*) is important — COUNT(*) would return 1 for customers with no orders because the LEFT JOIN still produces one row.
COUNT(*)
Solve Customer Order Summary yourself →