Given a dataset of customer subscriptions, how would you write a query to identify customers who upgraded their plans twice within the same calendar year?
Use the provided subscription history, customer, and plan data. Treat a change to a plan with a higher plan level as an upgrade, and identify customers with at least two upgrades in one calendar year.
Output
- One row per qualifying customer and calendar year
- Columns:
customer_id, customer_name, upgrade_year, upgrade_count, first_upgrade_date, and last_upgrade_date
- Include only customer-years with at least two upgrades
- Order by
customer_id, then upgrade_year ascending