Advertisement
michaelpastes

Untitled

Sep 16th, 2013
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.28 KB | None | 0 0
  1.  
  2. function my_aggregate() {
  3. db.zips.aggregate([{ $match: { state: { $in: [ "CA", "NY" ] } }},{ $group:{ _id : { "state" : "$state","city" : "$city" }, pop : { $sum: "$pop"}}},{ $match: { pop: { $gt: 25000 } }},{$group:{ _id : { "city" : "$city"}, pop : { $avg: "$pop"}}}]);
  4.  
  5.  
  6. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement