Practice real aggregation pipeline problems. Each question includes hints, a full solution pipeline, and a direct link to try it in the playground.
8
Questions
2
Easy
3
Medium
Hard
Calculate the total revenue and order count for each order status. Sort results by total revenue descending.
Find the top 3 customers by total spend. Return their name, email, total spent, and number of orders.
Find which products have been ordered most. Unwind the items array, group by productId, and return top 5 by total quantity.
Calculate total revenue per month. Use $addFields to extract the month from createdAt, then group and sort chronologically.
For each department, calculate average salary, min/max salary, and headcount. Sort by average salary descending.
Build a dashboard using $facet that simultaneously returns: (1) orders by status, (2) top 3 cities by order count, (3) total revenue.
Find the most common skills across all employees. Unwind the skills array, group, sort by count, and return top 10.
Group employees into salary bands: 0-100k, 100k-150k, 150k-200k, 200k+. Show count and list of names per band.