SQLQuokka
Start practicing
QuestionsLearnSandboxFeaturesRoadmapFAQ

Monthly Net Revenue by Customer

Unsolved

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.

SQL Query Editor (Ctrl+Enter to run)
0 characters · Valid
Canonical Solution Official

Official Solution is Hidden

Try solving the question with the schema explorer and hints first. When ready, reveal the verified canonical query and step-by-step logic breakdown.

Community Q&A & Discussion

Ask questions, share alternate queries, and explore solutions

0 comments
Asked By:
🏢 Stripe

Submission History

Your recent query executions and answer checks

Execution Pipeline:
FROM payments
Full source dataset
6 rows total
Ready. Type a query to see live execution.
Clause: Auto-Sync · AlaSQL Engine