Pipeline Practice

MongoDB $avg

Calculate the average of numeric values.

Use it inside `$group` when you need a mean for each group. Non-numeric and missing values are ignored rather than counted as zero.

Accumulators combine values from several input documents. You will use them most often inside `$group` and `$bucket` to build totals and averages.

Course use: Exercise 08 and Hard Mode 13.

Example pipeline syntax

{ $group: { _id: "$channel", averageOrder: { $avg: "$total" } } }