Skip to content

Instantly share code, notes, and snippets.

@mbforr
Last active January 8, 2023 10:25
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save mbforr/3e1457c392ce68c47a259cd1e7bff76f to your computer and use it in GitHub Desktop.
WITH
nyc AS (
SELECT
*
FROM
PROJECT.DATASET.nyc
LIMIT
10000)
SELECT
COUNT(a.vendor_id),
COUNT(c.vendor_id),
b.geo_id
FROM
bigquery-public-data.geo_census_blockgroups.us_blockgroups_national b
JOIN
nyc a
ON
st_intersects(a.geom,
b.blockgroup_geom)
JOIN
nyc c
ON
st_intersects(c.geom,
b.blockgroup_geom)
GROUP BY
b.geo_id
ORDER BY
COUNT(a.vendor_id) DESC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment