Flag Dormant and Unclaimed Savings Accounts From Transaction History
Last updated: November 29, 2026
Quick Overview
Using an accounts table and a transactions table, classify every open savings account as ACTIVE, DORMANT (no customer-initiated transaction in 2 years) or UNCLAIMED (none in 10 years) as of a given date.
Infosys
November 29, 20260
0
0 solved
Using an accounts table and a transactions table, classify every open savings account as ACTIVE, DORMANT (no customer-initiated transaction in 2 years) or UNCLAIMED (none in 10 years) as of a given date.
Banks running Finacle must report inoperative accounts to regulators, and Infosys data engineers build these extracts on client warehouses. The interviewer checks whether you ask which transactions count as activity, handle accounts with no transactions at all, and keep the cutoff date a parameter.
What the Interviewer Expects
- Ask what counts as activity (customer-initiated versus bank-posted interest or charges)
- Aggregate the latest qualifying transaction per account before joining
- Use a LEFT JOIN so accounts with zero transactions are included
- Fall back to the open date when there is no activity
- Parameterize the as-of date instead of using the current date
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 make this incremental for a table with billions of transactions?
- Regulations differ by country. How would you make the thresholds configurable per product?
- How would you record the date an account changed status, not just its current status?
- What index or partitioning would you add on the transactions 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, account_type, opened_on, status) and transactions(txn_id, account_id, txn_date, amount, initiated_by). Key question: does interest credited by the bank keep an ac...
Approach
Compute the last customer transaction per account in a CTE, which keeps the join one row per account. LEFT JOIN accounts to it, take COALESCE(last_txn_date, opened_on) as last activity, and bucket w...