MongoDB
C100DBA · Question #34
Consider that you have a collection called population which has fields state and city. Which of the following query will calculate the population grouped by state and city?
Sign in or unlock C100DBA to reveal the answer and full explanation for question #34. The question stem and answer options stay visible for context.
MongoDB Fundamentals
Question
Consider that you have a collection called population which has fields state and city. Which of the following query will calculate the population grouped by state and city?
Options
- Adb.population.aggregate( [{ $group: { _id: { state: "$state", city: "$city" },pop: { $pop: 1 } } }] )
- Bdb.population.aggregate( [{ $group: { _id: { city: "$city" },pop: { $sum: "$pop" } } }] )Multi
- Cdb.population.aggregate( [{ $group: { _id: { state: Estate", city: "$city" },pop: { $sum: "$pop" } } }] )
- Ddb.population.aggregate( [{ $group: { _id: { state: Estate", city: "$city" },pop: { $sum: 1 > > >] )
Unlock C100DBA to see the answer
You've previewed enough free C100DBA questions. Unlock C100DBA for full answers, explanations, the timed quiz mode, progress tracking, and the master PDF. Question stem and options stay visible so you can still see what's on the exam.
Topics
#aggregation#$group#$sum#pipeline