Back to problems

Write SQL to backtest refund policy

SQL · DoorDash · Hard

The tables below model a food-delivery platform. Your job is to write one SQL query (CTEs are allowed) that backtests a proposed cold-food refund policy against recent history. Assume "today" is the fixed date 2025-09-01, so only orders whose order_placed_at lands in the trailing 30 days — from 2025-08-02 through 2025-09-01, both inclusive — are in scope. Schema: Sample rows (illustrative only): Join orders to both deliveries and refunds, and for every order derive its…

Checking your access…