Skip to content
ClickHouse Docs
ClickHouse DocsClickHouse Docs

sum

sum

引入版本:v1.1.0

计算数值之和。

语法

sum(num)

参数

返回值

返回这些值的总和。(U)Int*Float*Decimal*

示例

计算员工工资总和

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 │
└─────────────┘
Navigation