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 for Top Maintenance Issues
00:00
5 left

SQL for Top Maintenance Issues

MediumSQL · PostgreSQL

Problem

A logistics company wants to identify recurring maintenance problems at each facility. Write a SQL query that analyzes work orders created during the one-year period ending on September 26, 2026, and returns the most frequent issues for each facility.

Output

  1. One row per facility and maintenance issue, including facility_id, facility_name, issue_id, issue_name, and issue_count.
  2. Include only work orders with non-null facility and issue identifiers that fall from September 26, 2025 through September 26, 2026, inclusive.
  3. Return no more than the three most frequent issues for each facility.
  4. Break equal counts by issue_name ascending, then issue_id ascending. Order the final result by facility_id, issue_count descending, issue_name ascending, and issue_id ascending.

Schema

facilities
ColumnTypeDescription
facility_idPKINTUnique facility identifier
facility_nameVARCHAR(100)Facility display name
regionVARCHAR(50)Operational region
maintenance_issues
ColumnTypeDescription
issue_idPKINTUnique maintenance issue identifier
issue_nameVARCHAR(100)Maintenance issue description
severityVARCHAR(20)Issue severity classification
maintenance_work_orders
ColumnTypeDescription
work_order_idPKINTUnique work order identifier
facility_idINTFacility associated with the work order
issue_idINTMaintenance issue associated with the work order
created_atDATEWork order creation date
statusVARCHAR(30)Current work order status
Tablesfacilitiesmaintenance_issuesmaintenance_work_orders
Interviewer

Your question is SQL for Top Maintenance Issues. 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.