Brug $map til den ydre array og $filter med $max til den indre.
{ $map: { input: "$inquiries", as: "inquiry", in: { routeHistory: { $filter: { input: "$$inquiry.routeHistory", cond: { $eq: [ { $max: "$$inquiry.routeHistory.routeDate" }, "$$this.routeDate" ] } } } } } }Hvis $map ikke understøttes, kan $unwind og $group bruges.