db.employee.aggregate([ { "$group": { "_id": "$country", "total_employees": { "$sum": 1 }, "total_sal": { "$sum": "$salary" }, "avg_sal": { "$avg": "$salary" } }}, { "$match": { "avg_sal": { "$gt": 10000 } } } ]);