SUM() GROUP BY ...
All functions > GROUP BY > SUM() GROUP BY ...
Returns the sum of the values in the group.
Syntax
Diagram(
Sequence(
Terminal("SUM"),
Terminal("("),
NonTerminal("expr"),
Terminal(")"),
Choice(0, Skip(),
Sequence(
Terminal("FILTER"),
Terminal("("),
Terminal("WHERE"),
NonTerminal("condition"),
Terminal(")")
)
),
Choice(0, Skip(),
Sequence(
Terminal("GROUP BY"),
OneOrMore(NonTerminal("feature"), Terminal(","))
)
)
)
)| Parameter | Type | Required | Description |
|---|---|---|---|
expr | T | Yes | The numeric expression to sum |
condition | BOOLEAN | No | The condition to filter the values before aggregation |
feature | FEATURE | No | The features to group by (many features are supported) |
With:
T: Any numeric type
Notes
- Adds all numeric values in the group
- NULL values are excluded from the calculation
- Returns NULL if all values are NULL or group is empty
- Result type matches input type
- Can overflow for large sums depending on the database engine
- Can be used with WHERE clause to filter before aggregation
- Can be used with GROUP BY clause for grouped aggregation