
Asana’s growth team wants to compare early retention for users acquired through ChatGPT versus all other acquisition channels. Write a PostgreSQL query that builds weekly signup cohorts and reports week 0 through week 4 retention for each cohort and acquisition segment.
users.signup_date.ChatGPT when acquisition_channel = 'ChatGPT'Other for every other non-null channel
Exclude users with a null acquisition channel.n if they had at least one activity in Asana during the nth week after signup, using activity_date from user_activity.cohort_week, acquisition_segment, and week_number for weeks 0-4.cohort_size, retained_users, and retention_rate rounded to 4 decimal places.cohort_week, acquisition_segment, and week_number.users| column | type | description |
|---|---|---|
| user_id | INT | Unique user id |
| signup_date | DATE | Date the user signed up for Asana |
| acquisition_channel | VARCHAR(50) | Signup acquisition source |
| workspace_id | INT | First workspace joined |
user_activity| column | type | description |
|---|---|---|
| activity_id | INT | Unique activity event id |
| user_id | INT | User who performed the activity |
| activity_date | DATE | Date of the activity |
| activity_type | VARCHAR(50) | Activity performed in Asana |
users| user_id | signup_date | acquisition_channel | workspace_id |
|---|---|---|---|
| 3 | 2024-01-10 | Paid Search | 101 |
| 1 | 2024-01-02 | ChatGPT | 101 |
| 8 | 2024-01-17 | Referral | 105 |
| 5 | 2024-01-09 | ChatGPT | 103 |
user_activity| activity_id | user_id | activity_date | activity_type |
|---|---|---|---|
| 104 | 1 | 2024-01-15 | task_completed |
| 101 | 1 | 2024-01-03 | task_created |
| 112 | 5 | 2024-01-23 | comment_added |
| 118 | 8 | 2024-02-15 | task_created |
| cohort_week | acquisition_segment | week_number | cohort_size | retained_users | retention_rate |
|---|---|---|---|---|---|
| 2024-01-01 | ChatGPT | 0 | 2 | 2 | 1.0000 |
| 2024-01-01 | ChatGPT | 1 | 2 | 1 | 0.5000 |
| 2024-01-01 | Other | 0 | 2 | 1 | 0.5000 |
| 2024-01-15 | Other | 4 | 1 | 1 | 1.0000 |
| Column | Type | Description |
|---|---|---|
| user_idPK | INT | Unique Asana user identifier |
| signup_date | DATE | Date the user signed up |
| acquisition_channel | VARCHAR(50) | Marketing or referral source that acquired the user |
| workspace_id | INT | First Asana workspace the user joined |
| Column | Type | Description |
|---|---|---|
| activity_idPK | INT | Unique activity event identifier |
| user_id | INT | User who performed the activity |
| activity_date | DATE | Date of the Asana activity |
| activity_type | VARCHAR(50) | Type of activity performed |
{"users":[["3","2024-01-10","Paid Search","101"],["1","2024-01-02","ChatGPT","101"],["8","2024-01-17","Referral","105"],["5","2024-01-09","ChatGPT","103"],["2","2024-01-04","Organic Search","102"],["10","2024-01-18","Paid Social","106"],["4","2024-01-11",null,"102"],["6","2024-01-15","ChatGPT","104"],["7","2024-01-16","ChatGPT","104"],["9","2024-01-22","ChatGPT",null],["11","2024-01-17","Instagram","105"],["12","2024-01-21","Newsletter","105"],["13","2024-01-02","null","107"],["14","2024-01-18",Output[["2023-12-25","Other","0","3","0","0.0000"],["2023-12-25","Other","1","3","0","0.0000"],["2023-12-25","Other","2","3","0","0.0000"],["2023-12-25","Other","3","3","0","0.0000"],["2023-12-25","Other","4","3","0","0.0000"],["2024-01-01","ChatGPT","0","1","1","1.0000"],["2024-01-01","ChatGPT","1","1","1","1.0000"],["2024-01-01","ChatGPT","2","1","0","0.0000"],["2024-01-01","ChatGPT","3","1","0","0.0000"],["2024-01-01","ChatGPT","4","1","0","0.0000"],["2024-01-01","Other","0","3","0","0.0000"],["202