Advertisement
YuvalGai

Untitled

Sep 8th, 2024
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. select
  2. a.interval_date,
  3. b.league ARENA_GROUP,
  4. b.trophy_group,
  5. b.country,
  6. b.LANGUAGE,
  7. b.platform,
  8. a.current_arena_index,
  9. b.app_version,
  10. b.app_minor_version,
  11. b.payers_segment,
  12. b.ltv_group,
  13. ACTION,
  14. video_type,
  15. REWARD_TYPE,
  16. sum(ad_value) total_ad_value,
  17. count(*) total_ads_watched,
  18. count(distinct a.user_id) users
  19. from
  20. (select *,date(derived_tstamp) interval_date from MATCH_MASTERS.PROD.F_VIDEO_WATCHED where date(derived_tstamp) > current_date - 180) a
  21. LEFT JOIN
  22. (SELECT
  23. user_id
  24. , interval_date
  25. , country
  26. , LANGUAGE
  27. , platform
  28. , app_version
  29. , app_minor_version
  30. , ltv_group
  31. , DATE(first_install_dt) AS install_date
  32. , payers_segment
  33. , CASE
  34. WHEN trophies_cnt < 1500 THEN '0-1500'
  35. WHEN trophies_cnt < 3800 THEN '1500-3800'
  36. WHEN trophies_cnt < 8000 THEN '3800-8000'
  37. WHEN trophies_cnt < 17000 THEN '8000-17000'
  38. WHEN trophies_cnt < 30000 THEN '17000-30000'
  39. ELSE '30000+'
  40. END AS trophy_group
  41. ,CASE
  42. WHEN trophies_cnt < 800 THEN '800'
  43. WHEN finish_arena<=13 THEN 'Studios'
  44. WHEN finish_arena<=22 THEN 'Master_League'
  45. WHEN finish_arena>=23 THEN 'Legends_League'
  46. END league
  47.  
  48. FROM MATCH_MASTERS.prod.daily_users_from_params WHERE interval_date >= current_date - 180) B
  49.  
  50. ON a.user_id = B.user_id AND a.interval_date = B.interval_date
  51.  
  52. GROUP BY
  53. 1,
  54. 2,
  55. 3,
  56. 4,
  57. 5,
  58. 6,
  59. 7,
  60. 8,
  61. 9,
  62. 10,
  63. 11,
  64. 12,
  65. 13,
  66. 14
  67.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement