Stripe finance reports net revenue per customer per month. Payments add money in the month they were paid. Refunds and chargebacks subtract money in the month they happened, which can be later than the original payment, and they belong to the customer of the original payment. A payment can have several refunds. Payments with a NULL customer_id are guest checkouts and must be reported under the name 'guest'. Write an SQL query that returns revenue_month (formatted YYYY-MM), customer_ref (the customer_id, or 'guest') and net_revenue (payments minus refunds minus chargebacks). Order the results by revenue_month, then customer_ref.
Loading…
Try solving the question with the schema explorer and hints first. When ready, reveal the verified canonical query and step-by-step logic breakdown.
Ask questions, share alternate queries, and explore solutions
Your recent query executions and answer checks
This will insert the verified MySQL solution into your editor so you can study how each clause transforms the table.