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 Yield Percentiles by State
00:00
5 left

SQL Yield Percentiles by State

HardSQL · PostgreSQL

Problem

Write a SQL query to find the top 10% of properties by yield in each state, given a table of property valuations and monthly rental income. Calculate yield using the latest valuation and the annualized average monthly rental income. Exclude properties without a valid valuation or rental income.

Output

  1. One row per qualifying property, with state, property_id, annual_yield_percent, valuation_amount, and avg_monthly_rental_income.
  2. Include at least one property per state; include ties at the cutoff.
  3. Order by state, descending annual_yield_percent, then property_id.

Schema

property_valuations
ColumnTypeDescription
valuation_idPKINTUnique valuation record identifier
property_idINTProperty identifier
stateVARCHAR(2)Two-letter property state code
valuation_amountDECIMAL(12,2)Property valuation amount
valuation_dateDATEDate of valuation
monthly_rental_income
ColumnTypeDescription
rental_income_idPKINTUnique rental income record identifier
property_idINTProperty identifier
income_monthDATEFirst day of the income month
monthly_rental_incomeDECIMAL(10,2)Rental income recorded for the month
Tablesproperty_valuationsmonthly_rental_income
Interviewer

Your question is SQL Yield Percentiles by State. 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.