$sum
The$sum operator returns the sum of all numeric input values.
Input
- An array of numeric values to sum
Output
- The sum of all input values (returns 0 if no values provided)
Examples
Sum of Multiple Values
10
Sum of Field Values
No Values
0Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
$sum operator returns the sum of all numeric input values.
{
"$sum": [
1,
2,
3,
4
]
}
10
{
"$sum": [
{
"$input": "value1"
},
{
"$input": "value2"
},
{
"$input": "value3"
}
]
}
{
"$sum": []
}
0