Write a SQL query to analyze weekly operational performance by Rivian facility, including throughput, defect rate, and week-over-week change.
Use the provided facility and production event data. Treat a missing defective-unit value as zero, and calculate week-over-week change as the percentage change in throughput from the prior reported week.
facility_name, week_start, throughput, defect_rate_pct, throughput_change_pct.facility_name, then week_start.| Column | Type | Description |
|---|---|---|
| facility_idPK | INT | Unique Rivian facility identifier |
| facility_name | VARCHAR(100) | Rivian facility name |
| region | VARCHAR(50) | Geographic operating region |
| Column | Type | Description |
|---|---|---|
| event_idPK | INT | Unique production event identifier |
| facility_id | INT | Facility where the event occurred |
| production_date | DATE | Date of production activity |
| units_produced | INT | Units produced during the event |
| defective_units | INT | Units identified as defective |