Write a SQL query to identify customers who made purchases in consecutive months for a Goldman Sachs dataset. Treat multiple purchases by the same customer within one calendar month as a single active month. Consecutive means adjacent calendar months, including across year boundaries.
customer_id, customer_name, consecutive_month_pairs, and first_consecutive_month.consecutive_month_pairs descending, then customer_id ascending.| Column | Type | Description |
|---|---|---|
| customer_idPK | INT | Unique Goldman Sachs customer identifier |
| customer_name | VARCHAR(100) | Customer's display name |
| Column | Type | Description |
|---|---|---|
| purchase_idPK | INT | Unique purchase identifier |
| customer_id | INT | Customer associated with the purchase |
| purchase_date | DATE | Date on which the purchase was recorded |
| amount | NUMERIC(12,2) | Purchase amount in dollars |