# sum

relationalai.semantics.std.aggregates

```python
sum(*args: AggValue) -> Aggregate
```

Compute the sum of values.

## Parameters

- `*args` (`AggValue`, default: `()`) - Values to sum. Can include Distinct wrapper for distinct aggregation.

## Returns

- `Aggregate` - An `Aggregate` representing the computation of the sum. Returns `Number` if the input is `Number`, or `Float` if the input is `Float`.

## Examples

Sum order amounts:

```python
select(aggregates.sum(Order.amount))
```

Sum employee salaries per department:

```python
select(Department, aggregates.sum(Employee.salary).per(Department))
```

## Referenced By

1. [RelationalAI Documentation](/index.md)1) [Build With RelationalAI](/build/index.md)1. [Use advanced reasoning](/build/reasoning/index.md)1) [Prescriptive reasoning](/build/reasoning/prescriptive/index.md) / [Solve a decision problem](/build/reasoning/prescriptive/decision-problems/index.md)1. [Add constraints](/build/reasoning/prescriptive/decision-problems/constraints/index.md)
         2) [Rules-based reasoning](/build/reasoning/rules-based/index.md)1) [Aggregate and group data](/build/reasoning/rules-based/aggregate-and-group-data/index.md)1. [Sum values with `.sum()`](/build/reasoning/rules-based/aggregate-and-group-data/index.md#sum-values-with-sum)
   2) [What's new](/release-notes/index.md)1) [Python package and CLI release notes](/release-notes/python/index.md)1. [Python package and CLI 2.0.1](/release-notes/python/2.0.1/index.md)1) [Bug Fixes](/release-notes/python/2.0.1/index.md#bug-fixes)
