Mercedes-Benz Group operations teams need a daily quality metric across active manufacturing lines. Write a PostgreSQL query that calculates the overall defect rate for each production date and its rolling seven-day average.
is_active = FALSE or NULL must be excluded.| Column | Type | Description |
|---|---|---|
| line_idPK | INTEGER | Manufacturing line identifier |
| line_name | VARCHAR(100) | Mercedes-Benz production line name |
| plant_code | VARCHAR(20) | Manufacturing plant code |
| is_active | BOOLEAN | Whether the line is currently active |
| Column | Type | Description |
|---|---|---|
| production_idPK | INTEGER | Production record identifier |
| line_id | INTEGER | Manufacturing line associated with the record |
| production_date | DATE | Production date |
| units_produced | INTEGER | Units produced on the line |
| defective_units | INTEGER | Units identified as defective |
| maintenance_note | TEXT | Optional production or maintenance note |