Write a SQL query using window functions to calculate a rolling 7-day average of daily bioprocess yield by customer and process stage.
Use the bioprocess_yields table. Calculate daily yield from all measurements recorded for the same customer, process stage, and date. Include dates with recorded measurements, including dates whose measurements are all NULL.
customer_name, process_stage, yield_date, daily_yield, and rolling_7_day_avg| Column | Type | Description |
|---|---|---|
| measurement_idPK | INT | Unique measurement identifier |
| customer_name | VARCHAR(100) | Customer associated with the measurement |
| process_stage | VARCHAR(50) | Bioprocess stage |
| yield_date | DATE | Date of the yield measurement |
| yield_pct | DECIMAL(6,2) | Measured bioprocess yield percentage |