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
Window Function for Rent Growth
00:00
5 left

Window Function for Rent Growth

MediumSQL · PostgreSQL

Problem

Write a window function to calculate the month-over-month rent growth for our portfolio across different zip codes.

Use the properties and rent_observations tables. Calculate each ZIP code's average monthly rent and its percentage change from the previous reported month. Exclude the first month for each ZIP code because it has no prior comparison.

Output

  1. One row per ZIP code and month with a prior reported month
  2. Columns: zip_code, month_start, average_rent, and rent_growth_pct
  3. Sort by zip_code, then month_start ascending

Schema

properties
ColumnTypeDescription
property_idPKINTUnique property identifier
property_nameVARCHAR(100)Property name
zip_codeVARCHAR(5)Property ZIP code
rent_observations
ColumnTypeDescription
observation_idPKINTUnique rent observation identifier
property_idINTProperty associated with the observation
observed_onDATEDate of the rent observation
monthly_rentNUMERIC(10,2)Observed monthly rent amount
Tablespropertiesrent_observations
Interviewer

Your question is Window Function for Rent Growth. 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.