PostgreSQLAggregate 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
lifetime_value
orders
SELECT customer_id, SUM(total_amount) AS lifetime_value
FROM orders
GROUP BY customer_id;