Write a SQL query to compare pre- and post-launch metrics by cohort using CTEs and joins.
Use the provided cohort assignments and metric observations. Treat observations from the 30 days before launch as pre-launch and observations from launch through the following 29 days as post-launch.
cohort_month, pre_avg_metric, post_avg_metric, absolute_change, and percent_change.cohort_month ascending.| Column | Type | Description |
|---|---|---|
| user_idPK | INT | Unique user identifier |
| cohort_month | DATE | Month assigned to the user cohort |
| launch_date | DATE | Launch date applicable to the user's cohort |
| Column | Type | Description |
|---|---|---|
| metric_idPK | INT | Unique metric observation identifier |
| user_id | INT | User associated with the observation |
| metric_date | DATE | Date of the metric observation |
| metric_value | DECIMAL(10,2) | Observed metric value |