Write a SQL query to find the average downtime of machines across different production plants.
Use the plants, machines, and downtime_events tables. Include every plant, including plants without recorded downtime, and ignore missing downtime durations.
plant_name and average_downtime_minutesNULL for their averageNULL values last, and break ties by plant name ascending.| Column | Type | Description |
|---|---|---|
| plant_idPK | INT | Unique production plant identifier |
| plant_name | VARCHAR(100) | Production plant name |
| country | VARCHAR(80) | Country where the plant operates |
| Column | Type | Description |
|---|---|---|
| machine_idPK | INT | Unique machine identifier |
| plant_id | INT | Production plant containing the machine |
| machine_name | VARCHAR(100) | Machine name or line designation |
| Column | Type | Description |
|---|---|---|
| event_idPK | INT | Unique downtime event identifier |
| machine_id | INT | Machine associated with the downtime event |
| downtime_minutes | DECIMAL(8,2) | Duration of downtime in minutes |
| event_type | VARCHAR(50) | Category of downtime event |