Write a SQL query to compare regional performance before and after a phased rollout using CTEs and subqueries.
Use the provided regional rollout dates and performance records. Compare each region's 30-day period before rollout with its 30-day period beginning on the rollout date. Exclude regions without valid performance data in both periods.
Output
- One row per eligible region with
region_name, before_total, after_total, before_average, after_average, percentage_change, and improvement_rank.
- Sort by
improvement_rank ascending, then region_name ascending.