Advertisement
kirzecy670

Untitled

Sep 20th, 2024
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 2.56 KB | None | 0 0
  1. with
  2. visitParamExtractString(addJson, 'id') AS event_id_,
  3.  
  4. exp_users as
  5.   (select uid,
  6.           if(MAX(visitParamExtractString(addJson, 'option') = 'new'), 'New', 'Old') as exp_group
  7.    from stat.funnelTrack
  8.    where dt >= '2024-08-16'
  9.      and `action` = 'pmr_overlay_push'
  10.      and region in ('ru', 'global')
  11.      and appVersion >= 2007731
  12.    group by 1),
  13.    
  14. groups as
  15.   (select exp_group,
  16.           uniqExact(uid) as all
  17.    from exp_users eu
  18.    group by 1),
  19.    
  20. pushes_sent_new as
  21.   (select es.exp_group,
  22.           count(user_uid) as users
  23.    from analytics.pushes_sent ps
  24.    join exp_users es on ps.user_uid = es.uid
  25.    where sub_type = 'PF'
  26.      and dt >= '2024-08-16'
  27.      and es.exp_group = 'New'
  28.    group by 1),
  29.    
  30. pushes_sent_old as
  31.   (select es.exp_group as exp_group,
  32.           count(uid) as users
  33.    from stat.funnelTrack ft
  34.    join exp_users es on ft.uid = es.uid
  35.    where action = 'custom_push'
  36.      and visitParamExtractRaw(addJson, 'type') = '1224'
  37.      and dt >= '2024-08-16'
  38.      and es.exp_group = 'Old'
  39.      group by 1),
  40.  
  41. pushes_sent_old_info as
  42.   (select event_id_ as event_id,
  43.           uid
  44.    from stat.funnelTrack
  45.    join exp_users using(uid)
  46.    where action = 'custom_push'
  47.      and visitParamExtractRaw(addJson, 'type') = '1224'
  48.      and dt >= '2024-08-16'
  49.      and exp_group = 'Old'),
  50.  
  51. pushes_open_old AS (
  52.     SELECT
  53.         eg.exp_group as exp_group,
  54.         count(ft.uid) as uid
  55.     FROM
  56.         stat.funnelTrack ft
  57.     JOIN
  58.         exp_users eg ON ft.uid = eg.uid
  59.     JOIN
  60.         pushes_sent_old_info pi ON pi.uid = ft.uid AND pi.event_id = visitParamExtractString(addJson, 'event')
  61.     WHERE
  62.         action = 'push_open'
  63.         AND dt >= '2024-08-16'
  64.         and exp_group = 'Old'
  65.         GROUP BY exp_group
  66. ),
  67.  
  68. pushes_open_new as
  69.   (select exp_group,
  70.           count(if(action='overlay_btn_target', uid, null)) as overlay_btn_target
  71.    from stat.funnelTrack
  72.    join exp_users using(uid)
  73.    where dt >= '2024-08-16'
  74.      and action = 'overlay_btn_target'
  75.      and region in ('ru', 'global')
  76.      and exp_group = 'New'
  77.    group by 1)
  78.  
  79. select gs.exp_group as exp_group,
  80.        gs.all as users,
  81.        ps.users+su.users as sent,
  82.        sent/all as sent_per_user,
  83.        uae.uid+opo.overlay_btn_target as open,
  84.        open/sent as CTR
  85. from groups gs
  86. left join pushes_sent_new ps on gs.exp_group = ps.exp_group
  87. left join pushes_sent_old su on gs.exp_group = su.exp_group
  88. left join pushes_open_old uae on gs.exp_group = uae.exp_group
  89. left join pushes_open_new opo on gs.exp_group = opo.exp_group
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement