Write a SQL query using window functions to find the rolling average of freight shipping volume over a 7-day period at XPO.
Use the provided freight_shipments and calendar_dates tables. Include dates with no shipments as zero volume, and calculate each average using the current date and up to the six preceding calendar dates.
calendar_date, daily_volume, and rolling_7_day_avg.calendar_date ascending.| Column | Type | Description |
|---|---|---|
| shipment_idPK | INT | Unique shipment identifier |
| shipment_date | DATE | Date on which freight was shipped |
| freight_volume | DECIMAL(12,2) | Freight volume for the shipment |
| Column | Type | Description |
|---|---|---|
| calendar_datePK | DATE | Date included in the reporting calendar |