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 Portfolio KPIs
00:00
5 left

SQL for Portfolio KPIs

MediumSQL · PostgreSQL

Problem

Write a SQL query to track monthly occupancy, delinquency, and work order volume by market and compare them to the prior month.

Use the provided market and property monthly metrics data. Include markets with recorded monthly metrics and compare each market's current month with its immediately preceding month.

Output

  1. One row per market and month, ordered by market name and month.
  2. Columns: market_name, month_start, occupancy_rate, delinquency_amount, work_order_volume, prior_occupancy_rate, prior_delinquency_amount, prior_work_order_volume, occupancy_change, delinquency_change, and work_order_change.
  3. The first month for each market should have NULL prior-month values and NULL changes.

Schema

markets
ColumnTypeDescription
market_idPKINTUnique market identifier
market_nameVARCHAR(100)Market display name
regionVARCHAR(50)Broader operating region
property_monthly_metrics
ColumnTypeDescription
property_month_idPKINTUnique monthly property metric record
property_idINTProperty identifier
market_idINTMarket associated with the property
month_startDATEFirst day of the reporting month
total_unitsINTTotal units represented by the property
occupied_unitsINTOccupied units during the month
delinquency_amountDECIMAL(12,2)Monthly delinquent rent amount
work_order_countINTWork orders opened during the month
Tablesmarketsproperty_monthly_metrics
Interviewer

Your question is SQL for Portfolio KPIs. 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.