Skip to content

Instantly share code, notes, and snippets.

@tswast
Created March 3, 2017 22:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tswast/3274b895388ea22c602de74f372891a3 to your computer and use it in GitHub Desktop.
Save tswast/3274b895388ea22c602de74f372891a3 to your computer and use it in GitHub Desktop.
Count the number of people with each name in the [USA Names public dataset](https://cloud.google.com/bigquery/public-data/usa-names).
#standardSQL
SELECT
name,
name_total,
SUM(name_total) OVER(ORDER BY name ASC) AS name_cumulative
FROM (
SELECT
name,
SUM(number) AS name_total
FROM
`bigquery-public-data.usa_names.usa_1910_2013`
GROUP BY
name )
ORDER BY
name ASC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment