How would you write a query to identify the touchpoint that occurred immediately prior to a user upgrading to a paid plan at Retool?
Use the provided Retool users, touchpoints, and plan upgrades data. Return only upgrades with at least one earlier touchpoint, selecting the latest prior event and resolving timestamp ties by the highest touchpoint ID.
Output
- One row per qualifying paid-plan upgrade
- Columns:
upgrade_id, user_id, upgraded_at, touchpoint_id, touchpoint_type, touchpoint_at
- Order by
upgrade_id ascending