Given a table of user clicks and a table of purchases, write a query to find the conversion rate of users who clicked on a promoted item on Wish. Count a user as converted only when they purchased the same item after clicking it. Treat each user once in the denominator and numerator.
clicked_users, converted_users, and conversion_rate_pct.| Column | Type | Description |
|---|---|---|
| click_idPK | INT | Unique click identifier |
| user_id | INT | Wish user who clicked |
| item_id | INT | Clicked item identifier |
| clicked_at | TIMESTAMP | Time of the click |
| is_promoted | BOOLEAN | Whether the item was promoted |
| Column | Type | Description |
|---|---|---|
| purchase_idPK | INT | Unique purchase identifier |
| user_id | INT | User who made the purchase |
| item_id | INT | Purchased item identifier |
| purchased_at | TIMESTAMP | Time of the purchase |