Write a SQL query to compare planned dispatches versus actual completed loads by day and region, and flag regions where completion rate fell below target.
Use the provided tables and include days with planned dispatches but no completed loads, as well as completed loads without plans.
Output
- One row per day and region with
activity_date, region_name, planned_dispatches, completed_loads, completion_rate, and below_target
- Include all activity dates, calculate a zero completion rate when no dispatches were planned, and flag rates below the region target
- Order by
activity_date, then region_name