Sunday, September 7, 2014

M101J: MongoDB for Java Developers Homework 5.2

M101J: MongoDB for Java Developers Homework 5.2


Query:
db.zips.aggregate([ { $group:{ "_id":{ "state":"$state", "city":"$city" }, "pop":{ $sum:"$pop" } } }, { $match:{ "_id.state":{ $in:[ "CA", "NY" ] }, "pop":{ $gt:25000 } } }, { $group:{ "_id":null, "pop":{ $avg:"$pop" } } } ])


Answer is 44805

No comments:

Post a Comment