i have a dataset with some columns like countries, players, kd_ratio
i want to write a pipeline where i can group kd_ratio from all the countries and get the average.
Im trying this:
db.CSGO.aggregate([
{
$group: {
_id: { country: { $country: "$all" }, nick: { $nick: "$all" } },
averageQuantity: { $avg: "$kd_ratio" },
}}])
Based on what rickhg12hs the code will be this:
db.CSGO.aggregate([
{
$group: {
_id: '$country' ,
averageQuantity: { $avg: "$kd_ratio" },
}}])