Skip to content

Instantly share code, notes, and snippets.

@savelee
Created February 22, 2017 09:51
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 savelee/63845c95e8d9e1012a6dca733588e983 to your computer and use it in GitHub Desktop.
Save savelee/63845c95e8d9e1012a6dca733588e983 to your computer and use it in GitHub Desktop.
BigQuery Window Function example
#standardSQL
SELECT
corpus,
word,
word_count,
RANK() OVER (PARTITION BY corpus ORDER BY word_count DESC) rank
FROM
`publicdata.samples.shakespeare`
WHERE
LENGTH(word) > 10
AND word_count > 10
ORDER BY word_count DESC
LIMIT
40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment