Practical Exercise 2
Exercise: Sales Analytics
- Create an
orders collection with this data:
db.orders.insertMany([
{ customer: "John", product: "Laptop", amount: 1200, date: new Date("2024-01-15") },
{ customer: "Jane", product: "Phone", amount: 800, date: new Date("2024-01-20") },
{ customer: "John", product: "Mouse", amount: 25, date: new Date("2024-02-01") },
{ customer: "Bob", product: "Tablet", amount: 400, date: new Date("2024-02-10") }
])
- Calculate total sales per customer
- Find average order amount