> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-fix-nav-issues.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> 计算总和。仅适用于数值。

# sum

<div id="sum">
  ## sum
</div>

引入版本：v1.1.0

计算数值之和。

**语法**

```sql theme={null}
sum(num)
```

**参数**

* `num` — 数值类型的列。[`(U)Int*`](/zh/reference/data-types/int-uint) 或 [`Float*`](/zh/reference/data-types/float) 或 [`Decimal*`](/zh/reference/data-types/decimal)

**返回值**

返回这些值的总和。[`(U)Int*`](/zh/reference/data-types/int-uint) 或 [`Float*`](/zh/reference/data-types/float) 或 [`Decimal*`](/zh/reference/data-types/decimal)

**示例**

**计算员工工资总和**

```sql title=Query theme={null}
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;
```

```response title=Response theme={null}
┌─sum(salary)─┐
│      266140 │
└─────────────┘
```
