Build Ever-30-Days-Past-Due Vintage Curves by Approval Month

Last updated: November 29, 2026

Quick Overview

Given card accounts with an approval date and monthly delinquency snapshots (account, snapshot month, days past due), write SQL that returns, for each approval-month cohort and each month on book, the share of the cohort that has ever been 30 or more days past due by that month.

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

0

0

0 solved


Given card accounts with an approval date and monthly delinquency snapshots (account, snapshot month, days past due), write SQL that returns, for each approval-month cohort and each month on book, the share of the cohort that has ever been 30 or more days past due by that month.

Vintage curves are how credit teams at Nubank compare the quality of customers approved under different policies or channels, so credit and risk data scientists are expected to build them fluently. The interviewer checks cumulative (ever) logic, a fixed cohort denominator, month-on-book arithmetic and awareness of immature cohorts.

What the Interviewer Expects
  • Computes month on book as a month difference, not days divided by 30
  • Uses first time reaching 30+ DPD so the rate is cumulative and monotonic
  • Keeps the denominator as the full cohort, including accounts that later closed
  • Uses a LEFT JOIN so months with zero bad accounts appear
  • Mentions that recent cohorts only have early months
Key Topics to Cover
cohort analysis
window logic
credit vintage
SQL CTEs
denominators
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 weight by credit limit or balance instead of account count?
  • Accounts that charged off stop producing snapshots. Does your query still count them?
  • How would you plot and compare a policy change cohort against prior cohorts fairly?
  • How would you compute a 60+ DPD curve and a cure rate in the same pass?
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_accounts(account_id, approved_date) and delinquency_snapshots(account_id, snapshot_month, days_past_due) with one row per account per month starting in the approval month (month on book 0). A...

Approach
  1. Cohort each account by approval month. 2. Compute month on book per snapshot. 3. Find each account's first month on book at 30+ DPD. 4. For each cohort and month on book, count accounts whose first...

Submit Your Answer
Markdown supported

Related Questions