Created
July 30, 2021 02:31
-
-
Save mbforr/2a717cec73219511a89aeb0e37b384fd 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
# create an aggregated CTE first | |
WITH | |
zips_311 AS ( | |
SELECT | |
incident_zip, | |
COUNT(unique_key) AS count | |
FROM | |
`bigquery-public-data.new_york_311.311_service_requests` | |
GROUP BY | |
incident_zip ) | |
# join the CTE table below using zip code | |
SELECT | |
b.zip_code_geom, | |
a.incident_zip, | |
a.count | |
FROM | |
zips_311 a | |
JOIN | |
`bigquery-public-data.geo_us_boundaries.zip_codes` b | |
ON | |
a.incident_zip = b.zip_code | |
ORDER BY | |
a.count |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment