Skip to content

Instantly share code, notes, and snippets.

@feifangit
Created October 8, 2013 06:39
Show Gist options
  • Save feifangit/6880460 to your computer and use it in GitHub Desktop.
Save feifangit/6880460 to your computer and use it in GitHub Desktop.
MongoDB university M101P hw5.2
db.pop.aggregate([
{$group:{_id:{state:"$state",city:"$city"}, allpop:{$sum:"$pop"}}},
{$match:{allpop:{$gt:25000},"_id.state":{$in:["CA","NY"]}}},
{$group:{_id:null, avgpop:{$avg:"$allpop"}}}
]
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment