Problems / Last Touch Before Purchase / Editorial
[purchase_time - 7 days, purchase_time]
ROW_NUMBER() OVER (PARTITION BY purchase_id ORDER BY touch_time DESC)
rn = 1
COALESCE(channel, 'organic')
This is the as-of join — "for each left row, the most recent right row not after it" — the time-series workhorse behind price snapshots, config-at-event-time, and last-touch attribution. Relational engines express it as *bounded join + rank + keep-first*, and the grain discipline is everything: rank per purchase, or one purchase's touch silently answers for another. The 'organic' default is the other half of real attribution — absence of a match is itself a category, which is why the LEFT JOIN can't be skipped.
'organic'
Solve Last Touch Before Purchase yourself →