Day 3 — Answer Five Business Questions with SQL

Scenario

The e-commerce leadership team has agreed on KPI definitions, but the monthly business review still raises unanswered questions. Revenue has moved unevenly across regions, order volume is unclear, repeat purchasing may be weakening, and some product categories have rising returns.

You have been asked to produce a reliable SQL analysis before the next review. Your job is not just to make queries run: every result must have a clear grain, correct joins, and a business interpretation.

Dataset contract

Use a public or synthetic e-commerce dataset and map it to the following logical tables. If your source uses different names, document the mapping.

Table Expected grain Required fields
orders One row per order order_id (PK), customer_id, order_date, order_status, region_id
order_items One row per order line order_item_id (PK), order_id, product_id, quantity, unit_price, discount_amount, unit_cost
customers One row per customer customer_id (PK), signup_date, acquisition_channel
products One row per product product_id (PK), product_name, category
regions One row per region region_id (PK), region_name
returns One row per return event return_id (PK), order_item_id, return_date, quantity_returned, refund_amount, return_reason

Analysis rules

Your mission

Answer these five business questions with SQL.

1. Is sales performance improving?

Create a monthly trend showing:

State how you handle months with zero or missing sales.

2. What is happening to order volume and basket value?

For each month and region, calculate:

Make sure an order with multiple line items is counted once.

3. Are customer cohorts coming back?

Build a monthly cohort-retention table.

Use first purchase month—not signup month—as the cohort definition. Explain how you treat incomplete or partial months.

4. Which product categories have a returns problem?

By product category, calculate:

Avoid inflating sales or return totals when joining order lines to multiple return events. State whether your return rate is unit-based or order-based.

5. Where should leadership investigate first?

Create a monthly region-by-category view containing net sales, order count, and unit return rate. Compare each segment with the previous month.

Identify two region/category combinations that deserve investigation. For each one, state whether the evidence points more strongly to a sales-volume decline, weaker basket value, or worsening returns. Do not claim causation from a descriptive query alone.

Required deliverables

  1. One SQL file containing all five numbered queries, with comments and readable CTEs.
  2. Five result extracts (CSV or screenshots), one for each question.
  3. Data and grain notes describing table keys, join paths, filters, and any source-to-schema mapping.
  4. Validation checks for duplicate keys, order counts, sales totals, and return quantities. Explain any reconciliation differences.
  5. Five business interpretations—one per query—plus a short executive summary (maximum 150 words) naming the two segments you would investigate first.

Submission format

Submit in this order:

Constraints

Quality bar: Correct totals matter more than clever syntax. Every query must answer a business question, preserve the intended grain, and support a defensible interpretation.