AnalystPath

Wallet Balances After Transfers

SQLMediumMid level~15 min

Problem

A payments app gives each wallet a starting float. Every transfer moves money from one wallet to another. A wallet's balance is its starting float plus everything received minus everything sent.

Report, for each wallet, its current balance and whether it is **overdrawn** (balance below zero).

Return `wallet_id`, `holder`, `balance`, and `overdrawn` (the text `'Yes'` or `'No'`). Any order.

Tables

Example rows — the live problem includes the full dataset.

wallets
wallet_idholderopening
1Mireille100
2Tariq200
3Sven10000
transfers
transfer_idsender_idreceiver_idamountsent_on
1134002021-08-01
2325002021-08-02
3212002021-08-03

Expected output

Your answer should return 4 rows with the columns wallet_id, holder, balance, overdrawn.

Starter code (SQL)

SELECT *
FROM wallets;

Solve this SQL question free

Write SQL and run it instantly in your browser — even on your phone. No signup needed to try.

Solution & explanation

Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.

Sign up free to unlock

Related SQL questions