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
YoY Home Sales Growth Query
00:00
5 left

YoY Home Sales Growth Query

MediumSQL · PostgreSQL

Problem

Write a query to find the year-over-year growth in home sales for each geographic market at Redfin.

Use calendar years represented in the sales data and include every geographic market for every year in that range. Treat markets or years with no sales as zero. Return a null growth percentage when there is no prior-year comparison or the prior year has zero sales.

Output

  1. One row per market and calendar year.
  2. Columns: market_name, sales_year, home_sales_count, and yoy_growth_pct.
  3. Order by market_name, then sales_year ascending.

Schema

geographic_markets
ColumnTypeDescription
market_idPKINTUnique geographic market identifier
market_nameVARCHAR(100)Name of the geographic market
home_sales
ColumnTypeDescription
home_sale_idPKINTUnique home sale identifier
market_idINTGeographic market associated with the sale
sale_dateDATEDate the home sale closed
Tablesgeographic_marketshome_sales
Interviewer

Your question is YoY Home Sales Growth Query. 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.