Write a SQL query to calculate a 7-day rolling average of daily orders by store using window functions at Target.
Use the provided stores and orders tables. Include calendar dates with no orders so they contribute zero to the daily count. Treat the rolling average as the average of the current date and up to the six preceding calendar dates.
store_id, store_name, order_date, daily_orders, and rolling_7_day_avg.store_id, then order_date.| Column | Type | Description |
|---|---|---|
| store_idPK | INT | Unique Target store identifier |
| store_name | VARCHAR(100) | Target store display name |
| Column | Type | Description |
|---|---|---|
| order_idPK | INT | Unique order identifier |
| store_id | INT | Store where the order was placed |
| customer_id | VARCHAR(30) | Customer identifier associated with the order |
| order_date | DATE | Calendar date when the order was placed |