Advertisement
kirzecy670

Untitled

Jun 6th, 2025
440
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 0.82 KB | None | 0 0
  1. WITH new_user AS (
  2.     SELECT DISTINCT uid
  3.     FROM stat.funnelTrack
  4.     WHERE dt >= '2025-06-04'
  5.       AND appVersion >= 69550
  6.       AND deviceType = 2
  7.       AND appVersion % 2 = 0
  8.       AND action = 'open_first'
  9.       AND region = 'ru'
  10. ),
  11.  
  12. ax AS (
  13.     SELECT
  14.         ft.action as action,
  15.         uid IN (SELECT uid FROM new_user) AS is_new_user,
  16.         uniqExact(ft.uid) AS users,
  17.         sum(users) over (partition by action) as cohort
  18.     FROM stat.funnelTrack ft
  19.     WHERE ft.dt >= '2025-05-01'
  20.       AND ft.appVersion >= 69550
  21.       AND ft.deviceType = 2
  22.       AND ft.appVersion % 2 = 0
  23.     --   AND ft.action IN ('open_first', 'open', 'app_was_opened')
  24.       AND ft.region = 'ru'
  25.     GROUP BY ft.action, is_new_user
  26. )
  27.  
  28. SELECT *
  29. FROM ax
  30. where users >= 20
  31. ORDER BY cohort DESC, action, is_new_user;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement