Write a SQL query to compare conversion rates before and after a product launch using CTEs and aggregations at Kovai.
Use the provided product launch and user event data. Treat a user as converted within a period when the user has both a visit and a purchase for the same product during that period.
product_id, pre_conversion_rate, and post_conversion_rate.product_id ascending.| Column | Type | Description |
|---|---|---|
| product_idPK | INT | Unique identifier for the launched product |
| launch_date | DATE | Product launch date |
| Column | Type | Description |
|---|---|---|
| event_idPK | INT | Unique identifier for the user event |
| product_id | INT | Product associated with the event |
| user_id | INT | User who generated the event |
| event_date | DATE | Date on which the event occurred |
| event_type | VARCHAR(20) | Event action, such as visit or purchase |