Dear colleagues!
How is it possible that on this screenshot from video lesson they got a single value using accumulator $max within $project stage?
I thought the only way to get the single value for all documents is to use $group stage with _id:null.
I have tried to use $max within $project stage and as I aspected it gives multiple result - with one value for each document. my query was db.movies.aggregate([
{
$project: {
_id: 0,
highest_rating: { $max: “$imdb.rating” },
lowest_rating: { $min: “$imdb.rating” }
}
}
])
So how is it possible that in video they got the single value using $group stage?
thank you very much in advance!