Deutsche Telekom wants to compare subscription churn across regional product portfolios, including MagentaMobil, MagentaTV, and broadband products. Write a PostgreSQL query to identify the top three products by churn rate within each region for subscriptions started during the first half of 2025.
Requirements
- Join regions, products, and subscriptions using their key relationships.
- Calculate each product's churn rate as churned eligible subscriptions divided by eligible subscriptions, expressed as a percentage. A subscription is churned when
churned_at is not null.
- Include products with no eligible subscriptions, treating their churn rate as
0.00 percent.
- Rank products within each region by churn rate descending, then product ID ascending, and return only the top three products per region.
Output details
- Return columns in this order:
region_name, product_name, churned_subscriptions, eligible_subscriptions, churn_rate_pct, rank_in_region.
- Round
churn_rate_pct to two decimal places.
- Filter subscription start dates inclusively from
2025-01-01 through exclusively before 2025-07-01.
- Order the final results by
region_name ascending, then rank_in_region ascending.