PostgreSQL
PostgreSQL SUM
Calculate the total of numeric values.
Calculate a total
Assuming the table has a numeric price column, use SUM to add its non-null values:
SELECT SUM(price) AS total_price
FROM products;Use COALESCE(SUM(price), 0) when you want zero instead of null for a table with no matching values.