Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Build my plan
Rolling Default Rate by Vintage
00:00
5 left

Rolling Default Rate by Vintage

MediumSQL · PostgreSQL

Problem

dv01's loan performance analytics team needs to monitor default behavior for the January 2024 consumer-loan vintage. Write a PostgreSQL query that calculates the rolling three-month default rate for that vintage from January through May 2024.

Requirements

  1. Restrict the cohort to loans originated in January 2024.
  2. Count each loan only once, in the first month where defaulted is true. Treat NULL performance values as not defaulted.
  3. Include months with no defaults, and calculate the rolling three-month default rate as defaults in the current month and prior two months divided by the total size of the vintage.
  4. Return one row per month, ordered chronologically, with the month, monthly defaults, rolling defaults, and rate rounded to four decimal places.

Schema

loans
ColumnTypeDescription
loan_idPKINTUnique consumer loan identifier
origination_monthDATELoan origination month
loan_purposeVARCHAR(40)Purpose of the consumer loan
borrower_stateVARCHAR(2)Two-letter borrower state code
performance
ColumnTypeDescription
performance_idPKINTUnique monthly performance record
loan_idINTReferenced loan identifier
performance_monthDATEMonth of the performance observation
defaultedBOOLEANWhether the loan defaulted during the observation month
Tablesloansperformance
Interviewer

Your question is Rolling Default Rate by Vintage. Start with the requirements and the two tables in the Question tab.

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.
CodePostgreSQL
Sign up free to run your codeLog inLn 1
Run your query to see results here.