MySQLAggregate FunctionsSUM
COUNT

SUMAggregate Functions

AVG

Returns the sum.

Syntax

SUM(expr)

Example

Enter values below to update the example in real time.

customer_id
total_amount
total_spent
orders
-- 고객별 누적 주문 금액
SELECT customer_id, SUM(total_amount) AS total_spent
FROM orders
GROUP BY customer_id
ORDER BY total_spent DESC;