Advertisement
kirzecy670

Untitled

Aug 23rd, 2024
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. WITH
  2.     visitParamExtractString(addJson, 'option') AS option_,
  3.     visitParamExtractString(addJson, 'id') AS event_id_,
  4.     visitParamExtractInt(addJson, 'type') AS pushId_,
  5.     visitParamExtractString(addJson, 'event') AS event_,
  6. exp_users AS (
  7.     SELECT
  8.         uid,
  9.         option_ AS experiment_group_id
  10.     FROM
  11.         stat.funnelTrack
  12.     WHERE
  13.         dt >= yesterday()
  14.         AND action = 'pmr_2020_highlights_experiment'
  15. ),
  16. sent_pushes AS (
  17.     SELECT
  18.         dt,
  19.         uid,
  20.         pushId_ AS push_id,
  21.         event_id_ AS event_id,
  22.         experiment_group_id
  23.     FROM
  24.         stat.funnelTrack
  25.     JOIN
  26.         exp_users USING(uid)
  27.     WHERE
  28.         action IN ('cdp_push', 'admin_push', 'custom_push')
  29.         AND dt >= yesterday()
  30.     HAVING
  31.         push_id IN (520, 523, 524, 525, 526, 527, 530)
  32. ),
  33. opened_pushes AS (
  34.     SELECT
  35.         uid,
  36.         event_ AS event_id,
  37.         experiment_group_id
  38.     FROM
  39.         stat.funnelTrack
  40.     JOIN
  41.         exp_users USING(uid)
  42.     WHERE
  43.         action = 'push_open'
  44.         AND dt >= yesterday()
  45.         AND event_ IN (SELECT DISTINCT event_id FROM sent_pushes)
  46. )
  47. SELECT
  48.     eu.experiment_group_id,
  49.     eu.total_users,
  50.     sp.total_pushes_sent,
  51.     op.total_pushes_opened
  52. FROM
  53.     (SELECT experiment_group_id, uniqCombined(uid) AS total_users FROM exp_users GROUP BY experiment_group_id) eu
  54. LEFT JOIN
  55.     (SELECT experiment_group_id, uniqCombined(uid) AS total_pushes_sent FROM sent_pushes GROUP BY experiment_group_id) sp
  56. ON
  57.     sp.experiment_group_id = eu.experiment_group_id
  58. LEFT JOIN
  59.     (SELECT experiment_group_id, uniqCombined(uid) AS total_pushes_opened FROM opened_pushes GROUP BY experiment_group_id) op
  60. ON
  61.     op.experiment_group_id = eu.experiment_group_id;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement