Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. select
  2. [Play_Time]/[Sessions] as Session_Duration
  3. from(
  4. select
  5. sum ([T_Sessions]) / sum ([DAU]) as Sessions,
  6. sum ([T_SessionDuration]/60) / sum ([DAU]) as Play_Time,
  7. from(
  8. Select *
  9. from(
  10. select
  11. sum (allData.SessionDuration) as T_SessionDuration,
  12. COUNT(DISTINCT allData.SessionNumber) as T_Sessions,
  13. from(
  14. Select
  15. allData.SessionNumber,
  16. allData.distinct_id,
  17. allData.SessionDuration,
  18. allData.eventDate
  19. FROM
  20. (
  21. SELECT
  22. *,
  23. Date(time) as eventDate
  24. FROM TABLE_DATE_RANGE([cat-force-bi-19:EVENTS.FACT_], TIMESTAMP('2019-10-01'), TIMESTAMP('2019-10-22'))
  25. where version >= "0.2.0" and event = "Session_End"
  26. ) allData
  27. )
  28. group by allData.distinct_id, allData.eventDate
  29. ) DU_Data,
  30. (
  31. Select
  32. Count(distinct allData.distinct_id) as DAU,
  33. allData.eventDate
  34. FROM
  35. (
  36. SELECT
  37. *,
  38. Date(time) as eventDate
  39. FROM TABLE_DATE_RANGE([cat-force-bi-19:EVENTS.FACT_], TIMESTAMP('2019-10-01'), TIMESTAMP('2019-10-22'))
  40. where version >= "0.2.0" and event = "Session_End"
  41. ) allData
  42. group by allData.eventDate
  43. ) DAU_Data
  44. )
  45. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement