Salesforce Marketing Cloud wants to identify which products attract users who convert shortly afterward. Write a PostgreSQL query that finds the top three products viewed by users who made a purchase within 24 hours after the view.
interaction_type = 'view'.product_id ascending as a deterministic tie-breaker.| Column | Type | Description |
|---|---|---|
| event_idPK | INT | Unique interaction event identifier |
| user_id | INT | User who generated the interaction |
| product_id | INT | Viewed product identifier |
| interaction_type | VARCHAR(30) | Type of interaction, such as view or add_to_cart |
| occurred_at | TIMESTAMPTZ | Timestamp when the interaction occurred |
| Column | Type | Description |
|---|---|---|
| purchase_idPK | INT | Unique purchase identifier |
| user_id | INT | User who made the purchase |
| product_id | INT | Purchased product identifier |
| purchased_at | TIMESTAMPTZ | Timestamp when the purchase occurred |
| Column | Type | Description |
|---|---|---|
| product_idPK | INT | Unique Salesforce product identifier |
| product_name | VARCHAR(120) | Product name in the catalog |