Project: Sales Report
Group orders by customer.
Example
db.orders.aggregate([
{ $match: { status: "paid" } },
{ $group: { _id: "$customer", spent: { $sum: "$amount" } } },
{ $sort: { spent: -1 } },
{ $limit: 3 }
])Exercise
Top three.
{ $limit: }
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.