Calculates the total sum of numeric values in a column. Supports multiple numeric types and is highly efficient for large-scale data analysis in BigQuery.
Same as input type (INT64, FLOAT64, NUMERIC, or BIGNUMERIC)Diperbarui: 13 Jun 2026SUM(expression) | SUM(DISTINCT expression)A numeric column or expression to sum (INT64, FLOAT64, NUMERIC, BIGNUMERIC)
Sums only unique values
1 SELECT SUM(amount) as total_revenue 2 FROM `project.dataset.transactions` 3 WHERE DATE(transaction_date) = '2024-01-15';
Calculates total revenue for a specific date.
1 SELECT 2 product_category, 3 SUM(quantity) as total_sold, 4 SUM(amount) as total_revenue 5 FROM `project.dataset.sales` 6 GROUP BY product_category 7 ORDER BY total_revenue DESC;
Calculates total quantity sold and revenue per product category.
| product_category | total_sold | total_revenue |
|---|---|---|
| Electronics | 52300 | 87500000.00 |
| Fashion | 125000 | 31250000.00 |
| Food & Beverage | 89200 | 6250000.00 |
1 SELECT 2 SUM(amount) as total_sales, 3 SUM(IF(payment_method = 'credit_card', amount, 0)) as credit_card_sales, 4 SUM(IF(payment_method = 'bank_transfer', amount, 0)) as transfer_sales 5 FROM `project.dataset.transactions`;
Calculates total and a breakdown by payment method in a single query.
| total_sales | credit_card_sales | transfer_sales |
|---|---|---|
| 125000000.00 | 85000000.00 | 32500000.00 |
1 SELECT 2 order_date, 3 amount, 4 SUM(amount) OVER (ORDER BY order_date) as running_total 5 FROM `project.dataset.daily_sales` 6 ORDER BY order_date;
Calculates a cumulative running total of daily sales.
| order_date |
|---|
Sudah paham SUM? Latih langsung di browser
Latihan interaktif, langsung di browser.
| amount |
|---|
| running_total |
|---|
| 2024-01-01 | 1500000 | 1500000 |
| 2024-01-02 | 2300000 | 3800000 |
| 2024-01-03 | 1800000 | 5600000 |