easy · ~8 min
Account management needs a per-customer spend overview covering every registered account in customers.
customers
total_orders
0
total_amount
amount
avg_amount
name
city
Input contract: customer_id is unique and non-null in customers, and (name, city) uniquely identifies each customer and is non-null. order_id is unique and non-null in orders; customer_id and amount are non-null, and a customer may have zero, one, or many rows in orders.
customer_id
(name, city)
order_id
orders