Pipeline Practice

Compare sales channels

A useful report often combines multiple accumulators, then reshapes the grouped output into a clean contract for its consumer.

For completed orders, calculate order count, total revenue, and average order value per channel. Sort by revenue.

Expected result: Three clean channel summaries without `_id`.

Example pipeline syntax

[
  { $match: { status: "completed" } },
  { $group: { _id: "$channel", orderCount: { $sum: 1 } } }
]