/
aggregation-group.txt
124 lines (74 loc) · 2.91 KB
/
aggregation-group.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
===========================
Group Accumulator Operators
===========================
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
.. include:: /includes/intro-aggregation-accumulator.rst
.. include:: /includes/extracts/operators-toc-explanation.rst
.. list-table::
:widths: 30,70
:header-rows: 1
* - Name
- Description
* - :group:`$sum`
- Returns a sum of numerical values. Ignores non-numeric values.
.. versionchanged:: 3.2
Available in both :pipeline:`$group` and :pipeline:`$project`
stages.
* - :group:`$avg`
- Returns an average of numerical values. Ignores non-numeric values.
.. versionchanged:: 3.2
Available in both :pipeline:`$group` and :pipeline:`$project`
stages.
* - :group:`$first`
- Returns a value from the first document for each group. Order is
only defined if the documents are in a defined order.
Available in :pipeline:`$group` stage only.
* - :group:`$last`
- Returns a value from the last document for each group. Order is
only defined if the documents are in a defined order.
Available in :pipeline:`$group` stage only.
* - :group:`$max`
- Returns the highest expression value for each group.
.. versionchanged:: 3.2
Available in both :pipeline:`$group` and :pipeline:`$project`
stages.
* - :group:`$min`
- Returns the lowest expression value for each group.
.. versionchanged:: 3.2
Available in both :pipeline:`$group` and :pipeline:`$project`
stages.
* - :group:`$push`
- Returns an array of expression values for each group.
Available in :pipeline:`$group` stage only.
* - :group:`$addToSet`
- Returns an array of *unique* expression values for each group. Order of the
array elements is undefined.
Available in :pipeline:`$group` stage only.
* - :group:`$stdDevPop`
- Returns the population standard deviation of the input values.
.. versionchanged:: 3.2
Available in both :pipeline:`$group` and :pipeline:`$project`
stages.
* - :group:`$stdDevSamp`
- Returns the sample standard deviation of the input values.
.. versionchanged:: 3.2
Available in both :pipeline:`$group` and :pipeline:`$project`
stages.
.. toctree::
:titlesonly:
:hidden:
/reference/operator/aggregation/sum
/reference/operator/aggregation/avg
/reference/operator/aggregation/first
/reference/operator/aggregation/last
/reference/operator/aggregation/max
/reference/operator/aggregation/min
/reference/operator/aggregation/push
/reference/operator/aggregation/addToSet
/reference/operator/aggregation/stdDevPop
/reference/operator/aggregation/stdDevSamp