The Attribution Query (Marketing, UTM_parameter)

For the Attribution Query in sql to find the first and last touch along with the UTM_source, why do we have to use a inner join like:

with last_touch as **
(select user_id, max(timestamp) as 'last_touch_at’
** from page_visits

** group by 1)**

** select lt.user_id, lt.last_touch_at, pv.utm_source **
** from last_touch as ‘lt’**
** join page_visits as ‘pv’**
** on lt.user_id = pv.user_id and **
** lt.last_touch_at = pv.timestamp**

and not use a simple query like this:

select user_id, **
max(timestamp) as ‘last_touch_at’, **
** from page_visits

** group by 1;

When I checked, they both provided the same answer to me.

Hello @gigabyte233, the reason the exercise gets you to use an inner join is probably to get you practised at using them, but without giving you too much of a step from things you know how to do to new things; that would be my guess.