Database Reference
In-Depth Information
{
"_id" : "O",
"total" : 21865
},
...other output omitted...
{
"_id" : "Q",
"total" : 12831
}
],
"ok" : 1
}
This can, as mentioned, be combined with $skip and $limit commands.
For example, to find the top three elements:
> db.aggtest.aggregate([{$group:{_id:"$first",
total:{$sum:"$count"}}},{$sort:{total:-1}},{$limit:3}]);
{
"result" : [
{
"_id" : "H",
"total" : 27990
},
{
"_id" : "M",
"total" : 27188
},
{
"_id" : "L",
"total" : 25070
}
],
"ok" : 1
}
Search WWH ::




Custom Search