java_home
Sunday, June 29, 2014
Homework: Homework 5.2 (Hands On) , Crunching the Zipcode dataset , calculate the average population of cities in California (abbreviation CA) and New York (NY) (taken together) with populations over 25,000.
db.grades.aggregate([{$match:{state:{$in:["CA","NY"]}}},{$group:{_id:{city:"$city",state:"$state"},pop:{$sum:"$pop"}}},{$match:{"pop":{$gt:25000}}},{$group:{_id:null,total:{$avg:"$pop"}}}])
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment