Your question is Rolling Retention by Tier and Region. Start with the requirements and the three tables on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
OpenAI wants to evaluate subscription retention across ChatGPT plans and geographic regions. Write a PostgreSQL query that builds monthly retention cohorts from each user's first subscription and tracks product activity after signup.
Unknown.| Column | Type | Description |
|---|---|---|
| user_idPK | INTEGER | Unique OpenAI user identifier |
| region | VARCHAR(20) | User geographic region |
| Column | Type | Description |
|---|---|---|
| subscription_idPK | INTEGER | Unique subscription identifier |
| user_id | INTEGER | Subscribed user |
| tier | VARCHAR(20) | ChatGPT subscription tier |
| started_at | DATE | Subscription start date |
| Column | Type | Description |
|---|---|---|
| activity_idPK | INTEGER | Unique product activity event |
| user_id | INTEGER | User generating the activity |
| activity_date | DATE | Date of product activity |
| platform | VARCHAR(20) | Platform used for the activity |