MongoDB Tutorial 0/120 lessons ~6 min read Lesson 49
Group Stage
$group is the SQL GROUP BY of MongoDB.
Course progress0%
Focus
2 guided sections
Practice signal
Concept-first lesson
Career prep
Foundation builder
Introduction
$group is the SQL GROUP BY of MongoDB. It groups documents by a key and computes accumulators ($sum, $avg, $min, $max, $push) per group.
Syntax reference
js
{ $group: {_id: "$category",totalRevenue: { $sum: "$amount" },avgOrder: { $avg: "$amount" },count: { $sum: 1 }}}
Ready to mark this lesson complete?Track your journey across the entire course.