Project (Marketing Attribution For CoolTShirts.com) on Analyzing Data with SQL

Hi all,
This is my project for the CoolTShirt Marketing Attribution Project. Thank you in advance for the feedback.

-Terrence

I got the same answers so I like it!

I didn’t understand their suggestions for questions 3 & 4 to use a second temp table and add the campaign info in the original with statement. I also didn’t add the source since the question didn’t ask for it, but that was my preference (not a critique on what you did).

WITH last_touch AS (
    SELECT user_id,
          MAX(timestamp) as last_touch_at,
          utm_campaign
    FROM page_visits
    GROUP BY user_id
  )
SELECT utm_campaign,
      count(*) as 'last_touch_count'
FROM last_touch
GROUP BY 1
ORDER BY 2 DESC;