Created
November 2, 2016 19:44
-
-
Save nuria/9d4daaac2e910d02917e0fe740159ef1 to your computer and use it in GitHub Desktop.
hive group and count example
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 | |
| month, | |
| day, | |
| SUM(CASE WHEN (user_agent LIKE '%iPhone%') THEN 1 ELSE 0 END) AS iphone, | |
| SUM(CASE WHEN (user_agent LIKE '%iOS%') THEN 1 ELSE 0 END) AS iOS | |
| FROM wmf.webrequest | |
| WHERE webrequest_source = 'text' | |
| AND year = 2016 | |
| AND month IN (9, 10) | |
| AND (user_agent like '%iOS%' OR user_agent like '%iPhone%') | |
| AND (user_agent like '%Wikipedia/5.0%' OR user_agent like '%WikipediaApp%') | |
| GROUP BY | |
| month, | |
| day | |
| ORDER BY | |
| month, | |
| day | |
| LIMIT 1000; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment