Skip to content

Instantly share code, notes, and snippets.

@dudarev
Created September 17, 2014 08:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dudarev/bf7067f713a1e0fa901b to your computer and use it in GitHub Desktop.
Save dudarev/bf7067f713a1e0fa901b to your computer and use it in GitHub Desktop.
m101js.hw5.4.js
db.zips.aggregate([
{$project:
{
first_char: {$substr : ["$city",0,1]},
pop: 1
}
},
{$match:
{
first_char: {$lt: 'A'}
}
},
{$group:
{
_id: null,
total: {$sum: '$pop'}
}
}
])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment