Rank the Top Three ATMs per Region by Monthly Cash Dispensed
Last updated: November 29, 2026
Quick Overview
From ATM withdrawal records, return for each region the three ATMs that dispensed the most approved cash in October 2026, keeping ties.
Bank of America
November 29, 20260
0
0 solved
From ATM withdrawal records, return for each region the three ATMs that dispensed the most approved cash in October 2026, keeping ties.
A quick SQL check for teams that plan cash replenishment for BofA's large ATM network, where the busiest machines need armored car visits more often. The interviewer checks partitioned ranking, correct date bounds and tie handling.
What the Interviewer Expects
- Filter to approved withdrawals in a half-open date range
- Aggregate per region and ATM
- Rank within region with a window function
- Choose and justify RANK versus ROW_NUMBER versus DENSE_RANK
- Return deterministic ordering
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 instead rank by average daily dispense to be fair to ATMs installed mid-month?
- How would you find ATMs that ran out of cash, using balance snapshots?
- How would you partition this table for fast monthly queries?
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
atm_withdrawals(region, atm_id, txn_ts, amount_cents, status). Only approved withdrawals dispense cash. October means txn_ts in [2026-10-01, 2026-11-01), which includes 23:59 on the 31st. Ties: if...
Approach
Aggregate first, then rank, because a window function over raw rows would rank individual withdrawals. RANK() keeps ties and leaves gaps (1, 1, 3), so rnk <= 3 returns at most three distinct posit...