Skip to content

sum

relationalai.semantics.std.aggregates
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:

select(aggregates.sum(Order.amount))

Sum employee salaries per department:

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

Referenced By

RelationalAI Documentation
├──  Build With RelationalAI
│   └──  Understand how PyRel works > Use advanced reasoning
│       ├──  Prescriptive reasoning > Solve a decision problem
│       │   └──  Add constraints
│       └──  Rules-based reasoning
│           └──  Aggregate and group data
│               └──  Sum values with .sum()
└──  Release Notes
    └──  Python API Release Notes
        └──  What’s New in Version 1.17.0
            └──  Bug Fixes and Diagnostics