sum
Calculates the sum of numeric values.
This page describes the RawTree engine binary used to generate this reference. It does not define Query API support. Descriptions retain upstream ClickHouse terminology. See SQL interface scope.
Calculates the sum of numeric values.
Syntax
sum(num)Arguments
Returned value
Returns the sum of the values. (U)Int* or Float* or Decimal*
Examples
Computing sum of employee salaries
CREATE TABLE employees
(
id UInt32,
name String,
salary UInt32
)
ENGINE = Memory;
INSERT INTO employees VALUES
(87432, 'John Smith', 45680),
(59018, 'Jane Smith', 72350),
(20376, 'Ivan Ivanovich', 58900),
(71245, 'Anastasia Ivanovna', 89210);
SELECT sum(salary) FROM employees;┌─sum(salary)─┐
│ 266140 │
└─────────────┘Introduced in version 1.1.0.