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 Plant Downtime Analysis
00:00
5 left

SQL for Plant Downtime Analysis

MediumSQL · PostgreSQL

Problem

Write a SQL query to analyze plant downtime by month, joining operations logs and maintenance records to identify the top causes of lost production for DTE Energy.

Use 2025 operation records, include events without a matching maintenance record as Unclassified, and return the top three causes for each plant and month. Ties should share a rank.

Output

  1. One row per plant, month, and cause, with plant_name, month_start, cause, downtime_hours, lost_production_mwh, event_count, and cause_rank.
  2. Include only ranks through 3, ordered by plant, month, rank, and cause.

Schema

operations_logs
ColumnTypeDescription
event_idPKINTUnique identifier for an operational downtime event
plant_nameVARCHAR(100)DTE Energy plant where downtime occurred
downtime_startTIMESTAMPTimestamp when downtime began
downtime_minutesINTDuration of downtime in minutes
lost_production_mwhDECIMAL(12,2)Estimated production lost during the event
maintenance_records
ColumnTypeDescription
maintenance_idPKINTUnique maintenance record identifier
event_idINTOperational downtime event associated with the maintenance record
causeVARCHAR(100)Recorded maintenance cause of the downtime
Tablesoperations_logsmaintenance_records
Interviewer

Your question is SQL for Plant Downtime Analysis. 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.