Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
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 feedbackSuccess 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
Top Profitable Home Models
00:00
5 left

Top Profitable Home Models

MediumSQL · PostgreSQL

Problem

Write a SQL query to identify the top three most profitable home models across different regional divisions over the last fiscal year at Lennar.

Use the provided 2024 sales data as the last fiscal year. Profit is sale price minus construction cost. Return the top three models independently within each regional division.

Output

  1. One row per qualifying division and home model.
  2. Columns: division_name, model_name, total_profit, and model_rank.
  3. Include only complete 2024 sales records and the top three models in each division.
  4. Order by division name, rank, and model name.

Schema

regional_divisions
ColumnTypeDescription
division_idPKINTUnique regional division identifier
division_nameVARCHAR(100)Name of the regional division
home_models
ColumnTypeDescription
model_idPKINTUnique home model identifier
model_nameVARCHAR(100)Name of the Lennar home model
home_sales
ColumnTypeDescription
sale_idPKINTUnique home sale identifier
division_idINTRegional division associated with the sale
model_idINTHome model sold
sale_dateDATEDate the home sale was recorded
sale_priceDECIMAL(12,2)Final sale price
construction_costDECIMAL(12,2)Construction cost for the home
Tableshome_salesregional_divisionshome_models
Interviewer

Your question is Top Profitable Home Models. 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.