Advertisement
kirzecy670

Untitled

Jun 22nd, 2025
304
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. WITH
  2. reinstall AS (
  3.     SELECT DISTINCT uid
  4.     FROM stat.funnelTrack
  5.     WHERE dt >= '2025-01-01'
  6.       AND FMKIsAndroidParent(deviceType, appVersion)
  7.       AND (
  8.           (action IN ('bind_user', 'rebind_user')
  9.            AND visitParamExtractString(addJson, 'reason') IN (
  10.                'email', 'loginByEmailAndCode', 'restoreByAdId',
  11.                'adid', 'moveGlobalToRu', 'migration'
  12.            ))
  13.           OR action = 'reinstall_detected'
  14.       )
  15. ),
  16.  
  17. circle_owners AS (
  18.     SELECT user_id,
  19.            argMin(permission_role, id) AS role
  20.     FROM circles.circle_member
  21.     GROUP BY user_id
  22.     HAVING role = 'Owner'
  23. ),
  24.  
  25. first_open_users AS (
  26.     SELECT
  27.         uid,
  28.         full_reg_datetime::date AS cohort_date,
  29.         IF(uid IN (SELECT uid FROM reinstall), 'rebind', 'not_rebind') AS rebind_group,
  30.         IF(children_quantity >= 1, 'has_child', 'no_child') AS child_group
  31.     FROM analytics.parent_properties_v pp
  32.     JOIN circle_owners co ON co.user_id = pp.id
  33.     WHERE full_reg_datetime >= '2025-05-01'
  34.       AND platform = 'Android'
  35.       AND region = 'ru'
  36. ),
  37.  
  38. cohort_sizes AS (
  39.     SELECT
  40.         cohort_date,
  41.         concat(rebind_group, ' / ', child_group) AS user_group,
  42.         uniqExact(uid) AS cohort_size
  43.     FROM first_open_users
  44.     GROUP BY cohort_date, user_group
  45. )
  46.  
  47. SELECT
  48.     cohort_date,
  49.     user_group,
  50.     cohort_size
  51. FROM cohort_sizes
  52. ORDER BY cohort_date, user_group;
  53.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement