Created
February 22, 2017 09:45
-
-
Save savelee/13222587afc90483b552067e4469783e to your computer and use it in GitHub Desktop.
BigQuery JOIN example
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
#standardSQL | |
#Top name frequency in Shakespeare | |
WITH TopNames AS ( | |
SELECT | |
name, | |
SUM(number) AS occurrences | |
FROM | |
`bigquery-public-data.usa_names.usa_1910_2013` | |
GROUP BY | |
name | |
ORDER BY | |
occurrences DESC | |
LIMIT | |
100) | |
SELECT | |
name, | |
SUM(word_count) AS frequency | |
FROM | |
TopNames | |
JOIN | |
`bigquery-public-data.samples.shakespeare` | |
ON | |
STARTS_WITH(word, | |
name) | |
GROUP BY | |
name | |
ORDER BY | |
frequency DESC | |
LIMIT | |
10; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment