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
Cohort Default Rate SQL
00:00
5 left

Cohort Default Rate SQL

MediumSQL · PostgreSQL

Problem

Affirm risk analytics needs to monitor default rates by loan origination cohort. Write a PostgreSQL query that calculates the default rate for Affirm loans originated during the six complete calendar months ending July 2025.

Use 2025-07-31 as the reporting date. A loan is defaulted when its latest status on or before the reporting date is default.

Requirements

  1. Include cohorts from February 1 through July 31, 2025, grouped by origination month.
  2. Use a CTE and ROW_NUMBER() to select each loan's latest status.
  3. Return the cohort month, total originated loans, defaulted loans, and default rate.
  4. Include loans without a status record, treating them as not defaulted. Order cohorts chronologically.

Schema

loan_applications
ColumnTypeDescription
application_idPKINTApplication identifier
loan_idINTAffirm loan identifier
originated_atDATELoan origination date
productVARCHAR(40)Affirm financing product
principal_amountNUMERIC(12,2)Original principal amount
loan_status_history
ColumnTypeDescription
status_idPKINTStatus event identifier
loan_idINTRelated loan identifier
status_dateDATEDate of the status event
statusVARCHAR(20)Loan status
Tablesloan_applicationsloan_status_history
Interviewer

Your question is Cohort Default Rate SQL. 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.