Write a SQL query using window functions to calculate month-over-month changes in household enrollment and rank regions by growth within each country.
Use the provided enrollment and region tables. Include only region-month rows with a prior observed month for comparison.
country, region_name, enrollment_month, household_enrollment, mom_change, mom_growth_pct, and growth_rankcountry, enrollment_month, growth_rank, and region_name| Column | Type | Description |
|---|---|---|
| region_idPK | INT | Unique region identifier |
| country | VARCHAR(100) | Country containing the region |
| region_name | VARCHAR(100) | Region name |
| Column | Type | Description |
|---|---|---|
| enrollment_idPK | INT | Unique enrollment record identifier |
| household_id | VARCHAR(50) | Household identifier |
| region_id | INT | Region associated with the enrollment |
| enrollment_date | DATE | Date of enrollment |