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
Occupancy High, GSS Down
00:00
5 left

Occupancy High, GSS Down

MediumSQL · PostgreSQL

Problem

Write a SQL query to find days when occupancy was high but Guest Satisfaction Scores fell below the property average.

Treat occupancy of 90% or higher as high. Calculate each property's average from its non-null daily Guest Satisfaction Scores, and calculate one daily score per property and date.

Output

  1. One row per qualifying property and date
  2. Columns: property_id, property_name, occupancy_date, occupancy_rate, daily_gss, and property_avg_gss
  3. Include only high-occupancy days with a daily score below the property average
  4. Order by property_id, then occupancy_date ascending

Schema

properties
ColumnTypeDescription
property_idPKINTUnique property identifier
property_nameVARCHAR(150)Property display name
daily_occupancy
ColumnTypeDescription
occupancy_idPKINTUnique occupancy record identifier
property_idINTReferenced property
occupancy_dateDATEDate of the occupancy measurement
occupancy_rateDECIMAL(5,4)Occupied rooms divided by available rooms
guest_satisfaction
ColumnTypeDescription
feedback_idPKINTUnique feedback record identifier
property_idINTReferenced property
feedback_dateDATEDate associated with the feedback
gss_scoreDECIMAL(4,2)Guest Satisfaction Score from 0 to 10
Tablespropertiesdaily_occupancyguest_satisfaction
Interviewer

Your question is Occupancy High, GSS Down. 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.