Last active
October 25, 2024 04:09
-
-
Save ks--ks/7edf477ad699996a6d9433902dcb54ba to your computer and use it in GitHub Desktop.
User Engagement Histogram
This file contains hidden or 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 active.num_days_active | |
, COUNT(DISTINCT active.user_id) AS num_users -- get how many users have a number of active days | |
FROM ( | |
SELECT a.user_id, COUNT(DISTINCT a.created_at) AS num_days_active | |
FROM activity a | |
GROUP BY a.user_id) AS active | |
LEFT JOIN activity a2 ON a2.user_id = active.user_id | |
WHERE a2.created_at >= CURRENT_DATE - 28 | |
GROUP BY active.num_days_active | |
ORDER BY active.num_days_active ASC; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment