Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Rolling Default Rates SQL

MediumSQL · PostgreSQL00:00
Practice interviewer
In session
5 left
00:00

Your question is Rolling Default Rates SQL. Start with the requirements and the two tables on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

American Credit Acceptance wants to monitor default trends among recurring borrowers in its servicing portfolio. Write a PostgreSQL query that calculates monthly and rolling three-month default rates from borrower status records.

Requirements

  1. Include only borrowers whose borrower_type is Recurring.
  2. Aggregate valid loan statuses by calendar month, counting defaults and all known statuses.
  3. Calculate the rolling three-month default rate as the total defaults divided by total known statuses across the current month and previous two available months.
  4. Return one row per month, ordered chronologically. Exclude records with an unknown borrower, unknown status, or missing status from the rate calculation.

Schema

borrowers
ColumnTypeDescription
borrower_idPKINTEGERUnique borrower identifier
borrower_nameVARCHAR(100)Borrower name
borrower_typeVARCHAR(20)Borrower classification
origination_dateDATELoan origination date
loan_status_history
ColumnTypeDescription
status_idPKINTEGERUnique status record identifier
borrower_idINTEGERReferences borrowers.borrower_id
status_dateDATEDate of the observed loan status
loan_statusVARCHAR(20)Observed servicing status
Tablesborrowersloan_status_history
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results