The dv01 platform team wants to identify users who return on consecutive calendar days to make completed purchases. Write a PostgreSQL query that detects these repeat-purchase patterns from transaction timestamps.
status = 'completed' and non-null user_id values.user_id ascending.| Column | Type | Description |
|---|---|---|
| user_idPK | INT | Unique user identifier |
| username | VARCHAR(100) | User display name |
| Column | Type | Description |
|---|---|---|
| purchase_idPK | INT | Unique purchase identifier |
| user_id | INT | User associated with the purchase |
| purchased_at | TIMESTAMP | Timestamp when the purchase occurred |
| status | VARCHAR(20) | Purchase processing status |
| channel | VARCHAR(30) | Purchase origin channel |