Find Dormant Savings Accounts With No Customer Transactions in a Year

Last updated: November 29, 2026

Quick Overview

Given accounts and transactions tables, list every active savings account whose most recent customer-initiated transaction is more than 365 days old or that has never had one, ignoring system postings such as interest credits and charges.

TCS
Data Manipulation (SQL/Python)
Data Engineer
TCS
November 29, 2026
Data Engineer
Technical Screen
Data Manipulation (SQL/Python)
Easy

0

0

0 solved


Given accounts and transactions tables, list every active savings account whose most recent customer-initiated transaction is more than 365 days old or that has never had one, ignoring system postings such as interest credits and charges.

Banks served by TCS must flag inactive accounts for regulatory dormancy rules, and this kind of report is routine on data and support engagements. The interviewer checks LEFT JOIN handling of accounts with no rows, filtering on the join versus the WHERE clause, and date arithmetic.

What the Interviewer Expects
  • Use a LEFT JOIN or NOT EXISTS so never-used accounts appear
  • Put the customer-initiated filter in the join condition, not WHERE
  • Aggregate to the latest transaction per account
  • Compare against a clear as-of date
  • Return the last activity date for operations teams
Key Topics to Cover
LEFT JOIN
Aggregation
Date filtering
NULL handling
How to Approach This
  1. Clarify the schema and expected output format before writing queries.
  2. Use CTEs (WITH clauses) to break complex queries into readable steps.
  3. Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
  4. Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
  5. For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
  • Why does moving the channel filter into WHERE silently drop never-used accounts?
  • How would you exclude accounts opened less than a year ago?
  • How would you run this nightly on a billion-row transactions table?
  • How would you produce the list of accounts that became dormant today only?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice SQL Problems
Sample Answer
Clarify the Data

accounts(account_id, customer_id, product_type, status, opened_on) and transactions(txn_id, account_id, txn_ts, amount, initiated_by) where initiated_by is 'CUSTOMER' or 'SYSTEM'. Dormant means ...

Approach

Start from accounts so every candidate account appears, left join only customer transactions, take the max timestamp per account, and keep rows where that max is NULL or older than the cutoff....


Submit Your Answer
Markdown supported

Related Questions