Https://www.codecademy.com/paths/analyze-data-with-sql/tracks/analyze-data-sql-analyze-real-data/modules/analyze-data-sql-marketing-attribution/projects/analyze-data-sql-attribution-queries

Hi guys !! just a questions , what’s the difference between both codes : ( number 6)
for me their are the same but different results…don’t know why :confused:

take a look :

with

last_touch_at as (

select user_id, max(timestamp) as last_touch_click

from page_visits

group by 1),

source as (

select

lt.user_id,

lt.last_touch_click,

pv.utm_source,

pv.utm_campaign,

pv.page_name

from last_touch_at lt

join page_visits pv on

lt.user_id = pv.user_id and

pv.timestamp=lt.last_touch_click)

select source.page_name,

source.utm_source,

source.utm_campaign,

count(*)

from source

where source.page_name like ‘%Purchase%’

group by 3;

------- the result of this query is 358

with

last_touch_at as (

select user_id, max(timestamp) as last_touch_click

from page_visits

where page_name like ‘%purchase%’

group by 1),

source as (

select

lt.user_id,

lt.last_touch_click,

pv.utm_source,

pv.utm_campaign,

pv.page_name

from last_touch_at lt

join page_visits pv on

lt.user_id = pv.user_id and

pv.timestamp=lt.last_touch_click)

select source.page_name,

source.utm_source,

source.utm_campaign,

count(*)

from source

group by 3;

the result of this query is 361 which is correct.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.