Build a Monthly Delinquency Roll Rate Matrix in SQL

Last updated: November 29, 2026

Quick Overview

Given a table of month-end loan snapshots with each loan's delinquency bucket and balance, write SQL that produces the balance-weighted roll rate matrix showing what share of each bucket's balance moved to each bucket (including paid off and charged off) by the next month-end.

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

0

0

0 solved


Given a table of month-end loan snapshots with each loan's delinquency bucket and balance, write SQL that produces the balance-weighted roll rate matrix showing what share of each bucket's balance moved to each bucket (including paid off and charged off) by the next month-end.

Roll rates are a daily language at a consumer lender: credit and collections teams at OneMain use them to forecast losses and staff call centers. A data science screen uses this to check self-joins across periods, handling loans that disappear from the snapshot, and weighting by dollars rather than counts.

What the Interviewer Expects
  • Self-join each snapshot month to the following month by loan_id
  • Use a LEFT JOIN and classify missing next-month rows as paid off or charged off using a status table
  • Weight by the starting month's balance, not loan count, unless asked
  • Divide by the from-bucket total with a window function so each row sums to 1
  • Filter to a single transition month or average across months, and say which
Key Topics to Cover
roll rates
self join
window functions
credit risk
Snowflake SQL
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 turn the matrix into a loss forecast for the current portfolio?
  • Why might count-based and balance-based roll rates tell different stories?
  • How would you show seasonality, for example tax refund season in February and March?
  • How do you treat loans that were modified or re-aged between months?
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

Assume loan_snapshot(snapshot_month DATE, loan_id, bucket VARCHAR, principal_balance NUMERIC) with one row per open loan per month-end, buckets in {Current, 1-29, 30-59, 60-89, 90+}. Closed loans di...

Approach

Join month m to month m+1. If the loan exists next month, its to-bucket is the new bucket. If not, look up the closure reason. Sum starting balance by (from_bucket, to_bucket) and divide by the from_b...


Submit Your Answer
Markdown supported

Related Questions