Skip to content

Instantly share code, notes, and snippets.

@ilovejs
Created April 12, 2018 00:39
Show Gist options
  • Save ilovejs/c26e158ca22d9a324137a6f2369cee82 to your computer and use it in GitHub Desktop.
Save ilovejs/c26e158ca22d9a324137a6f2369cee82 to your computer and use it in GitHub Desktop.
histogram_in_pg.sql
SELECT
x,
WIDTH_BUCKET(x, 1, 10, 9) AS "x In Which Bucket ?"
FROM
generate_series(1, 10) x;
SELECT
ROW_NUMBER() OVER(),
*
FROM
generate_series(1, 10) x;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment