Write a SQL query to find the monthly active users on the Starbucks Rewards app who made purchases in consecutive months.
Use the users and purchases tables. Treat consecutive months as adjacent calendar months, regardless of the specific purchase dates. Multiple purchases by the same user in one month count once.
month_start and monthly_active_usersmonth_start ascending| Column | Type | Description |
|---|---|---|
| user_idPK | INT | Unique Starbucks Rewards app user identifier |
| user_name | VARCHAR(100) | User display name |
| Column | Type | Description |
|---|---|---|
| purchase_idPK | INT | Unique purchase identifier |
| user_id | INT | User who made the purchase |
| purchase_date | DATE | Date of purchase |
| purchase_channel | VARCHAR(30) | Purchase channel |