Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- with i as (
- select
- client_id,
- DATE(MIN(case when action = 'visit' then hitdatetime else null end)) as fst_visit_dt,
- DATE(MIN(case when action = 'registration' then hitdatetime end)) as registration_dt,
- MAX(case when action = 'registration' then 1 else 0 end) as is_registration
- from
- user_activity_log
- group by
- client_id
- ),
- y as (
- select
- client_id,
- SUM(payment_amount) as total_payment_amount
- from
- user_payment_log upl
- group by
- client_id
- )
- select
- ua.client_id,
- ua.utm_campaign,
- i.fst_visit_dt,
- i.registration_dt,
- i.is_registration,
- y.total_payment_amount
- from
- user_attributes ua
- left join i on
- ua.client_id = i.client_id
- left join y on
- y.client_id = ua.client_id
- limit 10;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement