- Reference >
- Operators >
- Aggregation Pipeline Operators >
- Group Accumulator Operators >
- $sum (aggregation)
$sum (aggregation)¶
On this page
Definition¶
-
$sum
¶ Calculates and returns the sum of all the numeric values that result from applying a specified expression to each document in a group of documents that share the same group by key.
$sum
ignores non-numeric values.$sum
is an accumulator operator available only in the$group
stage.$sum
has the following syntax:For more information on expressions, see Expressions.