SQLQuokka
Start practicing
QuestionsLearnSandboxFeaturesRoadmapFAQ

Accounts That Went Negative

Unsolved

PayPal's risk team wants to flag accounts whose running balance ever dropped below zero. The balance after a transaction is the sum of all that account's transactions up to and including it, processed in order of `txn_date`, with `txn_id` breaking ties on the same date. Deposits are positive amounts and withdrawals are negative. Return `account_id`, `first_negative_date` (the date of the first transaction after which the balance was below zero) and `lowest_balance` (the minimum running balance reached) for every account that ever went below zero. Order the results by `account_id` ascending.

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🏢 PayPal🏢 Block

Submission History

Your recent query executions and answer checks

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