Last active
August 3, 2017 09:58
-
-
Save geeknees/fb81e9b9f5cbb48564ab9d9c63505e7c to your computer and use it in GitHub Desktop.
cohort SQL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT count(1) as signed_up_users | |
FROM users | |
WHERE users.created_at >= now() - interval 2 day | |
AND users.created_at < now() - interval 1 day; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT count(distinct lessons.user_id) as logged_in_users | |
FROM lessons | |
WHERE lessons.start_date > now() - interval 1 day | |
AND lessons.start_date < now(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
count(distinct users.id) as signed_up_users, | |
count(distinct lessons.user_id) as logged_in_users | |
FROM users | |
LEFT JOIN lessons | |
ON users.id = lessons.user_id |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment