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.
plant_name, month_start, cause, downtime_hours, lost_production_mwh, event_count, and cause_rank.| Column | Type | Description |
|---|---|---|
| event_idPK | INT | Unique identifier for an operational downtime event |
| plant_name | VARCHAR(100) | DTE Energy plant where downtime occurred |
| downtime_start | TIMESTAMP | Timestamp when downtime began |
| downtime_minutes | INT | Duration of downtime in minutes |
| lost_production_mwh | DECIMAL(12,2) | Estimated production lost during the event |
| Column | Type | Description |
|---|---|---|
| maintenance_idPK | INT | Unique maintenance record identifier |
| event_id | INT | Operational downtime event associated with the maintenance record |
| cause | VARCHAR(100) | Recorded maintenance cause of the downtime |