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
ExperiencesCoaching
New
Practice
Mock InterviewsTimed interview simulations with feedbackSuccess 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
Get started
Rolling 30-Day Default Rate
00:00
5 left

Rolling 30-Day Default Rate

HardSQL · PostgreSQL

Problem

Given a table of loan repayments, how would you calculate the rolling 30-day default rate?

Assume a repayment is in default when defaulted is true. Calculate the rate for each date with at least one repayment, using the current date and prior 29 calendar days. Include rows with a null defaulted value in the repayment denominator but not in the default numerator.

Output

  1. One row per repayment date with repayment_date, repayment_count, default_count, and rolling_default_rate
  2. Include all dates with repayments, ordered chronologically
  3. Round rolling_default_rate to six decimal places

Schema

loan_repayments
ColumnTypeDescription
repayment_idPKINTUnique repayment identifier
loan_idVARCHAR(20)Loan associated with the repayment
repayment_dateDATEDate the repayment was recorded
defaultedBOOLEANWhether the repayment is in default
repayment_amountNUMERIC(12,2)Amount associated with the repayment
Tablesloan_repayments
Interviewer

Your question is Rolling 30-Day Default Rate. Start with the requirements and the one table 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.