Created
April 6, 2015 02:52
-
-
Save victorcastelan/f10fe2bee1ea0e8ff9bc to your computer and use it in GitHub Desktop.
MongoDB Querys
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Devuelve el registro que más respuestas VÁLIDAS tiene y menos SEGUNDOS, agrupado por email. Ordenado por VALIDAS DESC y | |
db.myDBTrivia.aggregate( | |
[ | |
{ | |
$group: | |
{ | |
_id: "$email", | |
validas: { $max: "$respuesta.validas"}, | |
segundos: { $min: "$respuesta.segundos"} | |
} | |
}, | |
{ | |
$sort : {"validas":-1, "segundos":1} | |
} | |
] | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment