Hi,
I made an aggregation query to investigate sample_mflix data on Atlas.
I tried to find the average, minimum, and maximum of the ratings by genre.
Everything seems to work fine except $max giving me “”.
I don’t understand why $max gives me a blank even though there are numbers inside a group.
Below is the pipeline.
[{$unwind: {
path: ‘$genres’,
}}, {$project: {
genres:1,
score:’$imdb.rating’
}}, {$sort: {
genres: 1,
score: 1
}}, {$group: {
_id: ‘$genres’,
avg_rating: {
$avg: ‘$score’
},
max_rating:{
$max:’$score’
},
min_rating:{
$min:’$score’
},
count:{
$count:{}
}
}}]