Created
March 5, 2020 08:42
-
-
Save dqtweb/da63dc0b9d46934ac7dfda78f24d1fba to your computer and use it in GitHub Desktop.
Complex Counts in Hive
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 | |
type | |
, count(*) | |
, count(DISTINCT u) | |
, count(CASE WHEN plat=1 THEN u ELSE NULL END) | |
, count(DISTINCT CASE WHEN plat=1 THEN u ELSE NULL END) | |
, count(CASE WHEN (type=2 OR type=6) THEN u ELSE NULL END) | |
, count(DISTINCT CASE WHEN (type=2 OR type=6) THEN u ELSE NULL END) | |
FROM | |
t | |
WHERE | |
dt in ("2012-1-12-02", "2012-1-12-03") | |
GROUP BY | |
type | |
ORDER BY | |
type | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment