Why do we need a JOIN when we can just SELECT in this exercise?


In this exercise, it is taught that we need a JOIN to get the utm_source for an attribution query.

WITH first_touch AS (
   SELECT user_id,
      MIN(timestamp) AS 'first_touch_at'
   FROM page_visits
   GROUP BY user_id)
SELECT ft.user_id,
FROM first_touch AS 'ft'
JOIN page_visits AS 'pv'
  ON ft.user_id = pv.user_id
  AND ft.first_touch_at = pv.timestamp;

However, the page_visits table already has the utm_source column. We can simply select the utm_source from page_visits, instead of creating a temporary table and joining page_visits again. Like so:

SELECT user_id,
  MIN(timestamp) AS 'first_touch_at', utm_source
FROM page_visits

My question is then, why do we need to perform a join? Are there any differences in the query result between the 2 methods?