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.
performance_date, hub, station, total_flights, on_time_flights, on_time_percentage, and total_delay_minutes.| Column | Type | Description |
|---|---|---|
| flight_idPK | INT | Unique flight identifier |
| scheduled_departure | TIMESTAMP | Scheduled departure timestamp |
| station_code | VARCHAR(3) | Airport station code |
| hub_code | VARCHAR(3) | United hub associated with the flight |
| scheduled_arrival | TIMESTAMP | Scheduled arrival timestamp |
| actual_arrival | TIMESTAMP | Actual arrival timestamp |
| flight_status | VARCHAR(20) | Operational status of the flight |
| Column | Type | Description |
|---|---|---|
| delay_record_idPK | INT | Unique delay record identifier |
| flight_id | INT | Flight associated with the delay |
| delay_category | VARCHAR(30) | Category explaining the delay |
| delay_minutes | INT | Minutes attributed to the delay |