Measure Overdraft Repayment Speed by Limit Tier in SQL

Last updated: November 29, 2026

Quick Overview

Given an events table of overdraft advances and repayments and a table of each member's current limit, write SQL that reports, per limit tier and month of the advance, how many advances there were, the share fully repaid within 30 days, and the average days to clear. Repayments are applied to advances in first-in, first-out order.

Chime
Data Manipulation (SQL/Python)
Data Scientist
Chime
November 29, 2026
Data Scientist
Technical Screen
Data Manipulation (SQL/Python)
Medium

0

0

0 solved


Given an events table of overdraft advances and repayments and a table of each member's current limit, write SQL that reports, per limit tier and month of the advance, how many advances there were, the share fully repaid within 30 days, and the average days to clear. Repayments are applied to advances in first-in, first-out order.

A SQL screen in the style of Chime's analytics interviews, framed on SpotMe where repayment comes from the member's next deposits rather than a fixed schedule. The interviewer checks window functions, FIFO matching with running totals, and whether you notice right-censoring for recent advances.

What the Interviewer Expects
  • Clarify the FIFO repayment rule and the definition of cleared
  • Use running sums over advances and repayments
  • Find the first repayment that covers each advance's cumulative total
  • Bucket limits into tiers and group by advance month
  • Handle unrepaid and too-recent advances correctly
Key Topics to Cover
Window Functions
Running Totals
FIFO Matching
Censoring
Cohorts
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 do this if limits change over time and you need the limit at the time of advance?
  • How would you report it as a cohort curve (share cleared by day 1 to 60)?
  • Your query is slow on billions of rows. What would you change?
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

spotme_events(event_id, member_id, event_type, amount_cents, event_ts) with event_type in ('overdraft','repayment'); spotme_limits(member_id, limit_cents). An advance is cleared on the date when...

Approach

Running sum of advances per member (cum_od) and running sum of repayments (cum_rp), both ordered by time with event_id as a tiebreaker. For each advance, the clearing time is the earliest repaym...


Submit Your Answer
Markdown supported

Related Questions