Given a relational schema representing user subscriptions, write a SQL query to identify customers who upgraded their plans twice within a single month.
Use the customers, subscription_changes, and plans tables. An upgrade occurs when the new plan has a higher rank than the previous plan. Include customers with at least two upgrades in the same calendar month.
customer_id, customer_name, upgrade_month, and upgrade_countupgrade_month ascending, then customer_id ascending| Column | Type | Description |
|---|---|---|
| customer_idPK | INT | Unique customer identifier |
| customer_name | VARCHAR(100) | Customer display name |
| region | VARCHAR(50) | Customer billing region |
| Column | Type | Description |
|---|---|---|
| change_idPK | INT | Unique subscription change identifier |
| customer_id | INT | Customer affected by the change |
| old_plan_id | INT | Plan before the change, null for an initial subscription |
| new_plan_id | INT | Plan after the change |
| changed_at | TIMESTAMP | Timestamp when the plan change occurred |
| Column | Type | Description |
|---|---|---|
| plan_idPK | INT | Unique plan identifier |
| plan_name | VARCHAR(50) | Plan display name |
| plan_rank | INT | Ordinal level used to compare plan tiers |
| monthly_price | DECIMAL(10,2) | Monthly list price |