Skip to content

Instantly share code, notes, and snippets.

@anapaulagomes
Created September 8, 2015 02:58
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 anapaulagomes/7083e1d292e6c9d47308 to your computer and use it in GitHub Desktop.
Save anapaulagomes/7083e1d292e6c9d47308 to your computer and use it in GitHub Desktop.
Agrupa de acordo com parâmetros de busca e soma de acordo com um parâmetro da coleção - MongoDB
db.checkins.aggregate([
{ $match :
{
nome: 'AKB48劇場 (AKB48 Theater)',
classe: 'turista' }
},
{$group:
{
_id: '$horario',
checkins: {$sum: 1}}
},
{$sort: {checkins:-1} }
])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment