Stop 06 · Joining TablesProjects · 1/1

E-commerce Sales Analysis Case Study

Part of the SQL Roadmap

In short

This is the project that looks most like a real analyst job: messy business questions, several tables and a short report at the end. Interviewers love asking about it.

Answer realistic business questions on an e-commerce dataset with joins and GROUP BY: revenue by month and category, top customers, repeat buyers and products that never sell.

The jaadu walks through a warehouse of parcel shelves holding a clipboard.

Think of it like this

The online shop's warehouse walk

A new warehouse manager walks the aisles with a clipboard: which shelves empty fastest, which never move, which customers order every week. Your case study is that walk, done with SQL, ending with advice for the owner.

Watch it happen

The case study plan

Questions
Schema
Clean
Queries
Findings
Report

1/6Write 6 to 8 business questions: monthly revenue trend, top products, repeat customers, best cities.

The big ideas

What you need to know

Core e-commerce metrics

Revenue, orders, average order value, repeat purchase rate and top products. Define each clearly upfront.

Trends over time

Monthly revenue and order count show seasonality, like a festive season spike.

Customer behaviour

First-time vs repeat customers often tells a bigger story than total revenue.

Findings, not outputs

The report should say what to do. Raw query results belong in an appendix.

See it in code

Walk through the code

sql
1WITH customer_orders AS (2  SELECT customer_id, COUNT(*) AS orders, SUM(total_amount) AS spend3  FROM orders4  WHERE status = 'delivered'5  GROUP BY customer_id6)7SELECT8  CASE WHEN orders = 1 THEN 'one-time' ELSE 'repeat' END AS segment,9  COUNT(*)   AS customers,10  SUM(spend) AS revenue,11  ROUND(100.0 * SUM(spend) / SUM(SUM(spend)) OVER (), 1) AS pct_revenue12FROM customer_orders13GROUP BY 1;

1/3Per customer: how many delivered orders and how much they spent.

One-time vs repeat customers and their share of revenue. Assumes orders has a total_amount column; adjust to your dataset.

Save yourself the pain

Common mistakes

Oops

Including cancelled and test orders in revenue.

Do this instead

Decide and state your filters at the top of the report, then apply them in every query.

Oops

Ending with 15 tables of numbers and no conclusion.

Do this instead

Lead with three findings and three recommendations. Tables support the story, they aren't the story.

Your mission

Milestone one: questions and schema

~40 min

Quick check

Your report says average order value is ₹2,100. What should you state alongside it?

Go deeper

  1. 1Pick a public e-commerce dataset with customers, orders, order items and products tables.
  2. 2Write 8-10 business questions first, then answer each with one query.
  3. 3Summarise the findings in a short README with the key numbers and the queries behind them.

Stuck on this topic? Ask an Insider

Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.

Download
InsideEdge