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
Analyze On-Time Performance by Station
00:00
5 left

Analyze On-Time Performance by Station

MediumSQL · PostgreSQL

Problem

Write a SQL query to analyze daily on-time performance by station at United Airlines, joining flight operations data with delay reason data and aggregating by day and hub. Include completed flights only. A flight is on time when its actual arrival is no more than 15 minutes after its scheduled arrival.

Output

  1. One row per scheduled departure date, hub, and station.
  2. Return performance_date, hub, station, total_flights, on_time_flights, on_time_percentage, and total_delay_minutes.
  3. Include stations without delay records, calculate the percentage to two decimals, and order by date, hub, then station.

Schema

flight_operations
ColumnTypeDescription
flight_idPKINTUnique flight identifier
scheduled_departureTIMESTAMPScheduled departure timestamp
station_codeVARCHAR(3)Airport station code
hub_codeVARCHAR(3)United hub associated with the flight
scheduled_arrivalTIMESTAMPScheduled arrival timestamp
actual_arrivalTIMESTAMPActual arrival timestamp
flight_statusVARCHAR(20)Operational status of the flight
delay_reasons
ColumnTypeDescription
delay_record_idPKINTUnique delay record identifier
flight_idINTFlight associated with the delay
delay_categoryVARCHAR(30)Category explaining the delay
delay_minutesINTMinutes attributed to the delay
Tablesflight_operationsdelay_reasons
Interviewer

Your question is Analyze On-Time Performance by Station. 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.