hard · ~12 min
Marketing wants a first-touch attribution report crediting 100% of each purchasing customer's revenue to the channel of their earliest recorded marketing touch.
channel
Write a query that computes attributed customers and revenue per channel:
touch_time
touches
purchases
amount
customers
attributed_revenue
Input contract: touch_id is unique and non-null in touches; purchase_id is unique and non-null in purchases; all columns are non-null. Within each user_id, touch_time values are distinct (no earliest-touch ties), and a user may have multiple rows in touches across one or more channels as well as multiple rows in purchases.
touch_id
purchase_id
user_id