Find Dormant Checking Accounts at Risk of Escheatment
Last updated: November 29, 2026
Quick Overview
Given accounts and transactions tables, return every open checking account with no customer-initiated transaction in the last 365 days, with its last activity date and current balance.
Wells Fargo
November 29, 20260
0
0 solved
Given accounts and transactions tables, return every open checking account with no customer-initiated transaction in the last 365 days, with its last activity date and current balance.
Banks must flag inactive accounts and eventually turn unclaimed balances over to the state, so Wells Fargo data teams build exactly this kind of dormancy feed. The interviewer checks anti-join or LEFT JOIN skills, correct NULL handling for accounts that never transacted, and whether you notice that bank-initiated postings such as interest should not count as activity.
What the Interviewer Expects
- Use a LEFT JOIN or NOT EXISTS so accounts with zero transactions are included
- Filter to customer-initiated transaction types only
- Restrict to open checking accounts
- Handle the date boundary explicitly
- Return last activity date, NULL when there was never any
Key Topics to Cover
How to Approach This
- Clarify the schema and expected output format before writing queries.
- Use CTEs (WITH clauses) to break complex queries into readable steps.
- Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
- Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
- For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
- How would you change it to give a 30-day warning list before the account hits 365 days?
- Interest postings and monthly fees are not customer activity. How do you keep that list maintained?
- The transactions table has 10 billion rows. How do you make this fast?
- How would you make the job idempotent if it writes flags back to the accounts table?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice SQL ProblemsSample Answer
Clarify the Data
accounts(account_id, customer_id, product_type, status, opened_date, current_balance) and transactions(txn_id, account_id, txn_ts, txn_type, amount). I would confirm which txn_type values are cu...
Approach
Aggregate the latest customer-initiated transaction per account, LEFT JOIN that onto open checking accounts, and keep rows where the last activity is NULL or older than the cutoff. For never-used acco...