You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/50-aggregation/4-group.mdx
+18-16Lines changed: 18 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -3,14 +3,14 @@ import TabItem from "@theme/TabItem";
3
3
4
4
# π $group
5
5
6
-
In SQL, the GROUP BY statement groups rows that have the same values into summary rows, like "find the number of customers in each country".
6
+
In SQL, the GROUP BY statement groups rows that have the same values into summary rows, like "find the number of customers in each country."
7
7
The GROUP BY statement is often used with aggregate functions (COUNT(), MAX(), MIN(), SUM(), AVG()) to group the result-set by one or more columns.
8
8
9
9
The `$group` stage in MongoDBβs Aggregation Framework is equivalent to `GROUP BY` in SQL. It allows us to group documents by a specific field and apply aggregate functions like sum, average, count, min, and max.
10
10
11
11
---
12
12
13
-
## π¬ How Does $group Work?\*\*
13
+
## π¬ How does $group work?
14
14
15
15
The `$group` stage groups documents based on a field and performs calculations on grouped data.
16
16
@@ -25,14 +25,14 @@ The `$group` stage groups documents based on a field and performs calculations o
25
25
}
26
26
```
27
27
28
-
-`_id`: The field to group by (use `null` to aggregate all documents together).
0 commit comments