Flag Debit Card Customers Whose Spend Fell Below Half Their Trend

Last updated: November 29, 2026

Quick Overview

Using posted debit card purchases, find customers whose October 2026 spend is less than half of their average over the previous three months, as an early signal that they moved their primary spending elsewhere.

Bank of America
Data Manipulation (SQL/Python)
Data Scientist
Bank of America
November 29, 2026
Data Scientist
Technical Screen
Data Manipulation (SQL/Python)
Medium

0

0

0 solved


Using posted debit card purchases, find customers whose October 2026 spend is less than half of their average over the previous three months, as an early signal that they moved their primary spending elsewhere.

A SQL screen for consumer banking analytics, where a sudden drop in card spend often precedes a customer moving direct deposit to another bank. The interviewer checks window frames, filling missing months with zero, and sensible eligibility filters so the list is actionable for a retention campaign.

What the Interviewer Expects
  • Aggregate to customer by month on posted purchases only
  • Fill months with no spend as zero so the trailing average is honest
  • Use a 3-row window that excludes the current month
  • Require three full prior months and a minimum baseline
  • Order output by size of the drop
Key Topics to Cover
Window functions
Date spines
Left joins
Churn signals
Consumer banking analytics
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
  • How would you exclude seasonal customers such as snowbirds or students?
  • How would you separate a real drop from a lost or replaced card?
  • How would you turn this into a weekly scored feature for a churn model?
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

card_transactions(customer_id, txn_date, month_start, amount_cents, txn_type, status) where month_start is the first day of the posting month (a warehouse partition column), and a `calendar_months...

Approach
  1. Monthly spend per customer. 2) Build a spine of every month from first spend to October so a month with no purchases is a 0, not a missing row (missing rows would make the window reach further back...

Submit Your Answer
Markdown supported

Related Questions