Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- WITH
- visitParamExtractString(addJson, 'option') AS option_,
- visitParamExtractString(addJson, 'id') AS event_id_,
- visitParamExtractInt(addJson, 'type') AS pushId_,
- visitParamExtractString(addJson, 'event') AS event_,
- exp_users AS (
- SELECT
- uid,
- option_ AS experiment_group_id
- FROM
- stat.funnelTrack
- WHERE
- dt >= yesterday()
- AND action = 'pmr_2020_highlights_experiment'
- ),
- sent_pushes AS (
- SELECT
- dt,
- uid,
- pushId_ AS push_id,
- event_id_ AS event_id,
- experiment_group_id
- FROM
- stat.funnelTrack
- JOIN
- exp_users USING(uid)
- WHERE
- action IN ('cdp_push', 'admin_push', 'custom_push')
- AND dt >= yesterday()
- HAVING
- push_id IN (520, 523, 524, 525, 526, 527, 530)
- ),
- opened_pushes AS (
- SELECT
- uid,
- event_ AS event_id,
- experiment_group_id
- FROM
- stat.funnelTrack
- JOIN
- exp_users USING(uid)
- WHERE
- action = 'push_open'
- AND dt >= yesterday()
- AND event_ IN (SELECT DISTINCT event_id FROM sent_pushes)
- )
- SELECT
- eu.experiment_group_id,
- eu.total_users,
- sp.total_pushes_sent,
- op.total_pushes_opened
- FROM
- (SELECT experiment_group_id, uniqCombined(uid) AS total_users FROM exp_users GROUP BY experiment_group_id) eu
- LEFT JOIN
- (SELECT experiment_group_id, uniqCombined(uid) AS total_pushes_sent FROM sent_pushes GROUP BY experiment_group_id) sp
- ON
- sp.experiment_group_id = eu.experiment_group_id
- LEFT JOIN
- (SELECT experiment_group_id, uniqCombined(uid) AS total_pushes_opened FROM opened_pushes GROUP BY experiment_group_id) op
- ON
- op.experiment_group_id = eu.experiment_group_id;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement