Write a SQL query to calculate month-over-month changes in delivery performance using window functions.
Use promised_date to define the calendar month. Treat a shipment as on time when delivered_date is on or before promised_date; undelivered shipments count toward the monthly total but not as on time.
month, total_shipments, on_time_shipments, on_time_rate, prior_month_rate, and change_percentage_points.NULL for the first month's prior rate and change.| Column | Type | Description |
|---|---|---|
| shipment_idPK | INT | Unique shipment identifier |
| promised_date | DATE | Date by which the shipment was promised |
| delivered_date | DATE | Actual delivery date, or NULL if not delivered |
| service_level | VARCHAR(30) | Shipment service level |