D. Field name 'value' should be quoted and prefixed with $ inside $sum
Solution
Step 1: Check field reference inside $sum
The field 'value' must be referenced as "$value" (string with $ prefix) inside $sum.
Step 2: Confirm correct $group usage
The $group stage is present and _id is correctly set to "$type".
Final Answer:
Field name 'value' should be quoted and prefixed with $ inside $sum -> Option D
Quick Check:
Use "$field" inside $sum [OK]
Hint: Always quote and prefix field with $ inside $sum [OK]
Common Mistakes:
Using unquoted field names inside $sum
Thinking $sum can't be used in $group
Misunderstanding _id usage
5. You have a collection of sales documents with fields store and amount. You want to find the total sales per store but only for stores with total sales above 1000. Which aggregation pipeline correctly uses $sum and filters the results?