Search⌘ K
AI Features

Write Query: Multi-Stages Aggregation

The task involves analyzing customer spending trends for the year 2025 by calculating the total revenue and order count for each customer from the provided documents. The output should exclude customers with no purchases and present the results in a structured format, showing each customer's ID along with their total revenue and the number of orders placed during that year.

We'll cover the following...

Question 

Given the following sample documents from the customers collection:

[
  {
    "_id": "ee3c04494293e51a48af88d1",
    "name": "Michael Carter",
    "email": "michael.carter@gmail.com",
    "phone": "+1-206-555-0142",
    "address": {
      "street": "1206 Pine St",
      "city": "Seattle",
      "state": "WA",
      "postalCode": "98101",
      "country": "US"
    },
    "ordersCount":
...