Suggest an editImprove this articleRefine the answer for “What is aggregation in MongoDB?”. Your changes go to moderation before they’re published.Approval requiredContentWhat you’re changing🇺🇸EN🇺🇦UAPreviewTitle (EN)Short answer (EN)Aggregation in MongoDB is a mechanism for processing and transforming data within a collection to get a final result: statistics, grouping, filtering, sorting, counts, and so on; it works through a pipeline - a sequence of stages, each one changing or selecting data before passing it on. **Key point:** it lets you filter (`$match`), group (`$group`), sort (`$sort`), and pick fields (`$project`) all in one query, making it a powerful tool for reports and analytics instead of several separate queries.Shown above the full answer for quick recall.Answer (EN)ImageAggregation in MongoDB is a mechanism for **processing and transforming data within a collection** to produce a final result: statistics, grouping, filtering, sorting, counts, and so on. It works through a **pipeline**, a sequence of stages, where each stage transforms or selects data before passing it on. ### What this looks like An example pipeline: ```js db.sales.aggregate([ { $match: { status: "A" } }, // filtering { $group: { _id: "$item", total: { $sum: "$price" } } } // grouping and totaling ]) ``` ### What you can do with aggregation - `filter`, selecting only the documents you need (`$match`) - `group`, grouping and computing sums, averages, and so on (`$group`) - `sort`, sorting (`$sort`) - `project`, picking/changing fields (`$project`) - `limit/skip`, restricting the result set ### When it's used - statistics (sums, averages, max/min) - reports - complex queries instead of several separate ones - preparing data for analytics ### Summary Aggregation is a powerful MongoDB tool for analytics and data processing through a pipeline of stages, letting you filter, group, and compute final values in a single query.For the reviewerNote to the moderator (optional)Visible only to the moderator. Helps review go faster.