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
Top Facilities Maintenance Costs
00:00
5 left

Top Facilities Maintenance Costs

MediumSQL · PostgreSQL

Problem

Write a query to find the top three facilities by maintenance cost over the last quarter, partitioned by region.

For grading, treat the last quarter as April 1, 2025 through June 30, 2025. Include only facilities with the three highest totals in their region, with facility ID as the tie-breaker.

Output

  1. One row per selected facility, with region_name, facility_name, total_maintenance_cost, and facility_rank.
  2. Include up to three facilities per region, ordered by region_name, facility_rank, and facility_id.

Schema

regions
ColumnTypeDescription
region_idPKINTUnique regional identifier
region_nameVARCHAR(100)Region name
facilities
ColumnTypeDescription
facility_idPKINTUnique facility identifier
region_idINTRegion containing the facility
facility_nameVARCHAR(150)Facility name
maintenance_work_orders
ColumnTypeDescription
work_order_idPKINTUnique maintenance work order identifier
facility_idINTFacility receiving maintenance
maintenance_dateDATEDate of the maintenance work
maintenance_costNUMERIC(12,2)Cost of the maintenance work
Tablesregionsfacilitiesmaintenance_work_orders
Interviewer

Your question is Top Facilities Maintenance Costs. 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.