-
-
Save kiyoto/f26c994200f4989425e9b782b87e3f3e to your computer and use it in GitHub Desktop.
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
WITH by_week | |
AS (SELECT | |
user_id, | |
TD_DATE_TRUNC('week', login_time) AS login_week | |
FROM logins | |
GROUP BY 1, 2) | |
SELECT | |
user_id, | |
login_week, | |
FIRST_VALUE(login_week) OVER (PARTITION BY user_id ORDER BY login_week) AS first_week | |
FROM by_week |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment