Find Card Statements Where Payments Fell Short of the Minimum Due
Last updated: November 29, 2026
Quick Overview
Using pandas, join card statements (statement date, due date, minimum due) to payments and flag each statement where the total paid after the statement date and on or before the due date was less than the minimum due, with the shortfall amount.
Capital One
November 29, 20260
0
0 solved
Using pandas, join card statements (statement date, due date, minimum due) to payments and flag each statement where the total paid after the statement date and on or before the due date was less than the minimum due, with the shortfall amount.
Missing the minimum payment is the first step toward delinquency, so Capital One's collections and hardship teams track it closely. In a pandas take-home, the reviewer looks for a correct conditional join, statements with no payments kept in the output, and attention to the many-to-many blow-up.
What the Interviewer Expects
- Joins payments to statements on account and filters to the payment window
- Keeps statements with no payments and treats them as paid zero
- Sums payments per statement before comparing to the minimum
- Computes a non-negative shortfall
- Discusses memory cost of a merge followed by a filter and an alternative
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 avoid the cartesian merge for accounts with years of history?
- Should a payment returned for insufficient funds count?
- How would you turn this into a days-past-due measure?
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
statements(account_id, statement_date, due_date, min_due)andpayments(account_id, pay_date, amount).- A payment counts for a statement if
statement_date < pay_date <= due_date. - Returned pa...
Approach
Merge on account_id (one row per statement and payment pair), keep the amount only where the payment falls in the window, sum per statement, and merge back onto statements so empty statements surviv...