Use date arithmetic to find purchases within 7 days of campaign_id=1 sends
I'm trying to figure out email attribution. For each email campaign, how many customers who received the email actually made a purchase afterward? Need `campaign_name`, customers emailed, and customers who purchased. Watch out for the date ordering — a purchase only counts if it happened *after* the email was sent.
Each hint you reveal reduces the XP you can earn. Try the query first.
JOIN `fact_sends` to `fact_purchases` on `customer_id` — you're looking for customers who purchased after receiving an email from campaign 1
Both date columns (`sent_at`, `purchase_date`) are text. Cast them: `fp.purchase_date::date > fs.sent_at::date`
Add a 7-day window: `AND fp.purchase_date::date <= fs.sent_at::date + INTERVAL '7 days'`
Filter to campaign 1: `WHERE fs.campaign_id = 1`. Count the matches with `SELECT COUNT(*)`