Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- WITH ax AS
- (SELECT 'NA' AS ip_country,
- CASE
- WHEN toInt64OrNull(age) IS NULL THEN 'a. N/A'
- WHEN toInt64OrNull(age) = 0 THEN 'b. 0'
- WHEN toInt64OrNull(age) < 7 THEN 'c. 1-6'
- WHEN toInt64OrNull(age) < 11 THEN 'd. 7-10'
- WHEN toInt64OrNull(age) < 15 THEN 'e. 11-14'
- WHEN toInt64OrNull(age) < 18 THEN 'f. 15-17'
- WHEN toInt64OrNull(age) < 22 THEN 'g. 18-21'
- ELSE 'h. 22+'
- END AS age_group,
- COUNT(uid) AS n,
- sum(n) OVER (PARTITION BY ip_country) AS cohort
- FROM analytics.child_properties
- WHERE notEmpty(parents)
- AND ip_country != ''
- AND last_state_datetime >= '2023-01-01'
- GROUP BY 1, 2)
- SELECT
- --ip_country,
- age_group,
- n,
- round(n/cohort, 3) AS SHARE
- FROM ax
- ORDER BY 1, 2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement