Practice

20-Minute Joins and KPI Sprint

Practice Sprint Timer

Start with a first-correct query, then use remaining minutes for validation and cleanup.

20:00

This sprint focuses on fanout-safe joins and KPI rollups.

Time budget:

  • 0-8 min: Drill 1
  • 8-20 min: Drill 2

Drill 1: Category Revenue Mix #

For completed orders, return category-level metrics.

Required output columns:

  • category
  • completed_orders
  • revenue
Loading SQL editor...

Drill 2: Net Revenue by Month (After Returns) #

Build month-level gross, returned, and net revenue.

Attribution rule: attribute each return to the month of the original order (link returns to order items via order_item_id, and take the month from the order's order_date) - not to the month the return was filed. This keeps gross, returned, and net consistent within each month.

Required output columns:

  • month_start
  • gross_revenue (rounded to 2 decimals)
  • returned_amount (rounded to 2 decimals)
  • net_revenue (rounded to 2 decimals; equals gross_revenue - returned_amount)
Loading SQL editor...
Tip

Passing score target: >= 13/17. Prioritize grain correctness over micro-optimizations.