Skip to content

Instantly share code, notes, and snippets.

@fmariluis
Created June 18, 2013 14:49
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fmariluis/5805985 to your computer and use it in GitHub Desktop.
Save fmariluis/5805985 to your computer and use it in GitHub Desktop.
Create unique id field for a view in PostgreSQL
SELECT * FROM
( SELECT
ROW_NUMBER() OVER (ORDER BY column_to_sort_by ASC) AS ROW_NUMBER,
Col1, Col2
FROM table_name
) myview_name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment