SQLQuokka
Start practicing
QuestionsLearnSandboxFeaturesRoadmapFAQ

Failed Payment Recovery Time

Unsolved

Stripe wants to know how quickly customers recover after a failed payment. For every failed payment that is later followed by a successful payment from the same customer, find the first successful payment that happened after it and compute the whole minutes between the two. Failed payments with no later success are ignored. If a customer has several failed payments before one success, each failed payment gets its own row paired with that same success. Write an SQL query that returns customer_id, failed_payment_id, recovered_payment_id and minutes_to_recover. Order the results by customer_id, then failed_payment_id.

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
15 rows total
Ready. Type a query to see live execution.
Clause: Auto-Sync · AlaSQL Engine