【发布时间】:2016-12-04 01:32:34
【问题描述】:
所以目前我正在努力从我的查询中获得正确的结果。 这是它的外观:
db.pitching.aggregate([
{ $match: {} },
{ $group: {
_id: "$playerid",
maxIpouts: { $max: "$ipouts" }
}}
])
我知道我必须使用 $match 才能获得正确的结果。我想让一个玩家拥有最高的 ($max) ipout,但我不确定如何使用 $match 进行过滤。
如果没有 $match,它会给我 player_id 和玩家的每个 ipout,而不是具有最高 ipout 的单个玩家 id。
【问题讨论】:
标签: mongodb mongodb-query aggregation-framework