Write a SQL query using window functions to calculate a rolling 7-day average of shipments by route for Leaf Logistics.
Use calendar days between each route's first and last shipment date, treating days without shipments as zero. Exclude records with a missing route or shipment date.
route_id, shipment_date, daily_shipments, and rolling_7_day_avg.rolling_7_day_avg to two decimal places and order by route_id, then shipment_date.| Column | Type | Description |
|---|---|---|
| shipment_idPK | INT | Unique shipment identifier |
| route_id | VARCHAR(20) | Identifier of the shipment route |
| shipment_date | DATE | Date the shipment was recorded |