C100DEV Aggregation Framework Practice Question
A logistics company stores shipment documents in a collection named shipments. Each document has fields: `origin` (string), `destination` (string), `weight` (number), and `status` (string). The analytics team wants to find the total weight of shipments for each unique pair of origin and destination, but only for shipments with status 'delivered'. They also want to include the average weight per pair and sort the results by total weight descending. Which two stages are essential to achieve the grouping and calculation of these metrics? (Choose two.)
⚠ Common exam trap
The trap here is selecting $sort as essential because the requirement mentions sorting, but the question specifically asks for stages essential to grouping and calculation.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
$match
The $match stage filters shipments to only those with status 'delivered', and the $group stage aggregates by origin and destination, computing total weight and average weight. These two stages are essential to achieve the required grouping and calculations. Other stages like $sort are used for ordering but are not essential for the core aggregation.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
$match
Why this is correct
$match is essential to filter shipments with status 'delivered' before grouping. This reduces the number of documents processed by $group and ensures that only delivered shipments are included in the totals and averages. Placing $match early in the pipeline also allows MongoDB to use an index on status if available, improving performance. It is necessary to meet the filtering condition.
- ✓
$group
Why this is correct
$group is essential to aggregate documents by the composite key of origin and destination. It allows computing the total weight using $sum and the average weight using $avg. Without $group, you cannot perform these calculations across multiple documents. The $group stage will produce one document per unique origin-destination pair, containing the computed metrics. It is a fundamental stage for this requirement.
- ✗
$limit
Why it's wrong here
$limit restricts the number of documents passed to the next stage, but it does not contribute to grouping or calculating metrics. It could be used to limit the final result set, but it is not essential for the aggregation logic. The requirement does not specify a limit on the number of results, so $limit is not needed.
- ✗
$project
Why it's wrong here
$project can reshape documents by including or excluding fields or computing new ones, but it does not perform grouping or aggregation across documents. While it could be used after grouping to format the output, it is not essential for the core requirement of grouping and calculating metrics. The grouping and calculations are handled by $group, not $project.
- ✗
$sort
Why it's wrong here
$sort is used to order the results, which is required for the final output, but it is not essential for the grouping and calculation of metrics. The question asks for stages essential to achieve grouping and calculation, not the final sorting. While sorting is part of the overall requirement, it is not one of the two stages that perform the core aggregation and filtering.
About these practice questions
One of 259 original C100DEV practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
JA
Written and reviewed by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
Last reviewed September 2026 · checked against the official MongoDB exam blueprint
This C100DEV practice question is part of Courseiva's free MongoDB certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the C100DEV exam.