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
SQL for Occupancy and Delinquency
00:00
5 left

SQL for Occupancy and Delinquency

MediumSQL · PostgreSQL

Problem

Write a SQL query to calculate monthly occupancy rate, average rent, and delinquency rate by property from lease and payment tables.

Use January through March 2024 and evaluate lease occupancy on the first day of each month. Treat a payment with a NULL paid date as delinquent.

Output

  1. One row per property and month, including properties with no active leases or payments
  2. Columns: property_name, month, occupancy_rate_pct, average_rent, and delinquency_rate_pct
  3. Rates and rent must be rounded to two decimal places
  4. Order by property_name, then month ascending

Schema

properties
ColumnTypeDescription
property_idPKINTEGERUnique property identifier
property_nameVARCHAR(100)Property name
total_unitsINTEGERTotal rentable units
leases
ColumnTypeDescription
lease_idPKINTEGERUnique lease identifier
property_idINTEGERReferenced property
unit_idVARCHAR(20)Unit identifier
start_dateDATELease start date
end_dateDATELease end date, or NULL for an ongoing lease
monthly_rentNUMERIC(10,2)Monthly rent amount
payments
ColumnTypeDescription
payment_idPKINTEGERUnique payment identifier
lease_idINTEGERReferenced lease
due_dateDATEPayment due date
paid_dateDATEDate payment was made, or NULL if unpaid
Tablespropertiesleasespayments
Interviewer

Your question is SQL for Occupancy and Delinquency. Start with the requirements and the three 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.