Last active
December 6, 2020 01:38
-
-
Save YiLi225/e9b393d6f8240f5194a3e4bfe7c9f450 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
/** 1.2 User logins in both NYC and Illinois -- logic AND **/ | |
SELECT | |
id_var, user_var | |
FROM | |
( | |
SELECT | |
id_var, | |
user_var, | |
SUM(CASE WHEN location_var = 'NYC' THEN 1 ELSE 0 END) AS nyc_cnt, | |
SUM(CASE WHEN location_var = 'Illinois' THEN 1 ELSE 0 END) AS illinois_cnt | |
FROM | |
userlogin | |
GROUP BY id_var, user_var | |
) dat | |
WHERE | |
nyc_cnt > 0 | |
AND illinois_cnt > 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment