In short
This is the report every business asks for on the first of the month. You'll turn a raw orders table into a tidy month-by-month summary that a founder can read in thirty seconds.
A project where you produce a monthly table of orders, revenue, average order value and unique customers from a sales dataset.

Think of it like this
The shopkeeper's month-end bahi-khata
On the last night of the month, a kirana owner in Indore closes the shutter and sits with his red bahi-khata. He totals the bills, counts how many customers came, works out the average bill and compares it to a normal month. Your report is the same ledger, written in SQL so it rebuilds itself every month.
Watch it happen
From raw orders to a monthly report
1/6A year of orders from a Jaipur handicrafts store: date, customer, amount and status.
The big ideas
What you need to know
Pick the month key carefully
DATE_TRUNC('month', order_date) keeps the year. Grouping by month number alone mixes years.
Agree what counts
Decide with the business which statuses are 'sales'. Write the rule in the WHERE and in your notes.
Unique customers don't add up
Monthly unique customers can't be summed for a yearly total, because loyal customers appear in many months.
Numbers need words
Finish with three plain-English findings, like which month peaked and why you think it did.
How it works
Build the report
- 1
Load the data
Import a public retail dataset and check row counts and date ranges.
- 2
Define a sale
Agree on the statuses to include and the date column to use.
- 3
Aggregate by month
One row per month with orders, revenue, AOV and unique customers.
- 4
Add comparison
Show how each month differs from the average month.
- 5
Write findings
Add three short findings under the table and share it.
See it in code
Walk through the code
1WITH monthly AS (2 SELECT3 DATE_TRUNC('month', order_date)::date AS month,4 COUNT(*) AS orders,5 SUM(amount) AS revenue,6 ROUND(AVG(amount), 2) AS avg_order_value,7 COUNT(DISTINCT customer_id) AS unique_customers8 FROM orders9 WHERE status = 'delivered'10 GROUP BY DATE_TRUNC('month', order_date)11)12SELECT13 month, orders, revenue, avg_order_value, unique_customers,14 ROUND(revenue - (SELECT AVG(revenue) FROM monthly), 2) AS vs_avg_month15FROM monthly16ORDER BY month;1/4The month key and four headline numbers for each month.
The core query of the report. WITH names a step (you'll meet it properly in Phase 7). In MySQL, use DATE_FORMAT(order_date, '%Y-%m-01') for the month.
Save yourself the pain
Common mistakes
Oops
Grouping by EXTRACT(MONTH FROM order_date) on two years of data.
Do this instead
Use DATE_TRUNC('month', ...) so November 2025 and November 2026 stay separate.
Oops
Adding up the monthly unique_customers column for a yearly figure.
Do this instead
Run COUNT(DISTINCT customer_id) over the whole year instead. Repeat buyers are counted once per month.
Oops
Including cancelled orders in revenue.
Do this instead
Filter by status in WHERE, and say in the report which statuses you counted.
Your mission
Ship the report
Quick check
Your report shows 400 unique customers in October and 350 in November. How many unique customers did you have across both months?
Go deeper
- 1Use a public retail or e-commerce dataset and load it into your database.
- 2Add a column comparing each month's revenue to the overall average.
- 3Write three plain-English findings under your query results.
Stuck on this topic? Ask an Insider
Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.