Skip to content

Instantly share code, notes, and snippets.

@ittus
Created May 11, 2021 05:43
Show Gist options
  • Save ittus/aa4d2fc64fe66c8a9b93f0707acab046 to your computer and use it in GitHub Desktop.
Save ittus/aa4d2fc64fe66c8a9b93f0707acab046 to your computer and use it in GitHub Desktop.
[Medium] Cohort - 3
WITH user_activities AS (
SELECT A.person_id, DATEDIFF('day', C.start_time, date_trunc('day', A.start)::date) AS period_number
FROM activities A
LEFT JOIN new_users C ON A.person_id = C.person_id
GROUP BY 1, 2
HAVING period_number < 10
ORDER BY 1, 2
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment