3 ms·
> Let's ignore the [mongo] query format itself, as it's obviously meant to be generated by a tool rather than typed by a human being. Here's the same query in S
by sanityinc 13y ago
> Let's ignore the [mongo] query format itself, as it's obviously meant to be generated by a tool rather than typed by a human being. Here's the same query in SQL, with the result this time
Priceless.
- deleted 13y ago[deleted]
- threeseed 13y agoProbably easier to read if you write it this way: db.games.aggregate([ { $match : { date : { $gt : ISODate("1999-08-01T00:00:00Z"), $lt : ISODate("2000-08-01T00:00:00Z") }}}, { $unwind : '$teams' }, { $match : { 'teams.won' : 1 }}, { $group : { _id : '$teams.name', wins : { $sum : 1 }}}, { $sort : { wins : -1 }}, { $limit : 5 } ]);