-
-
Save vdt/d724fe49818069bd0305 to your computer and use it in GitHub Desktop.
BigQuery for most popular countries on Hacker News
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 | |
| b.country, | |
| SUM(score) as total_score, | |
| SUM(a.c) as mention_count, | |
| ROUND(SUM(score) / SUM(a.c), 2) as avg_score | |
| FROM | |
| ( | |
| SELECT | |
| a.word, | |
| SUM(a.score) AS score, | |
| COUNT(1) AS c | |
| FROM ( | |
| SELECT | |
| SPLIT(REGEXP_REPLACE(title, '[^a-zA-Z ]', ''), ' ') AS word, | |
| score | |
| FROM | |
| [fh-bigquery:hackernews.stories]) a | |
| GROUP BY | |
| a.word | |
| ) a | |
| JOIN | |
| [countries.country] b | |
| ON | |
| a.word = b.aka | |
| GROUP BY b.country | |
| HAVING mention_count >= 100 | |
| ORDER BY avg_score DESC | |
| LIMIT 100 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment