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/3-sort-limit.mdx
+41-6
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,6 @@
1
+
importTabsfrom"@theme/Tabs";
2
+
importTabItemfrom"@theme/TabItem";
3
+
1
4
# 👐 $sort and $limit
2
5
3
6
## 🔹 $sort → Sorting results
@@ -67,24 +70,54 @@ SELECT * FROM books ORDER BY timestamp DESC LIMIT 5;
67
70
68
71
---
69
72
70
-
###👐 Challenge
73
+
## 👐 Challenge
71
74
72
75
## 👐 1. After the year 2010, which book has the most number of authors?
73
76
74
77
<details>
75
78
<summary>Answer</summary>
76
79
<div>
77
-
```js
80
+
There are 2 ways to solve this-
81
+
- $project
82
+
- $addFields
83
+
84
+
:::info
85
+
Learn [when to use $addFields over $project](https://www.practical-mongodb-aggregations.com/guides/project.html?highlight=%24project#when-to-use-project)
0 commit comments