Last active
November 29, 2020 00:21
-
-
Save YiLi225/70de51ee31659a2c3d391f3762c94aa9 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
/** 3. User logins in California followed by Massachusetts **/ | |
SELECT * | |
FROM | |
( | |
SELECT | |
dat.*, | |
LEAD(location_var) OVER (PARTITION BY id_var ORDER BY date_var) AS next_location | |
FROM | |
userlogin dat | |
) dat2 | |
WHERE | |
location_var = 'California' AND next_location = 'Massachusetts' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment