db.restaurants.aggregate(
[
{ $match: { "borough": "Queens", "cuisine": "Brazilian" } },
{ $group: { "_id": "$address.zipcode" , "count": { $sum: 1 } } }
]
);
db.restaurants.aggregate(
[
{ $match: { "borough": "Queens", "cuisine": "Brazilian" } },
{ $group: { "_id": "$address.zipcode" , "count": { $sum: 1 } } }
]
);
1 回答1.3k 阅读✓ 已解决
2 回答1.5k 阅读
1 回答814 阅读✓ 已解决
1 回答1.4k 阅读
1 回答839 阅读
1 回答706 阅读
http://docs.mongodb.org/manual/reference/operator/aggregation/sum/
按表达式值求和 1代表1个