What SQL query would you use to calculate a rolling 7-day average of daily prescriptions by region using window functions?
Use the prescriptions table. Treat each region and calendar date as one daily total. The rolling average should include the current date and prior six calendar days where daily data exists.
region, prescription_date, daily_prescriptions, and rolling_7_day_avg.region, then prescription_date ascending.| Column | Type | Description |
|---|---|---|
| prescription_idPK | INT | Unique prescription record identifier |
| region | VARCHAR(50) | Geographic region associated with the prescription |
| prescription_date | DATE | Date on which the prescription was recorded |
| prescription_count | INT | Number of prescriptions in the record |