Skip to content

Instantly share code, notes, and snippets.

@bishwahang
Created December 7, 2017 21:14
Show Gist options
  • Select an option

  • Save bishwahang/636c57b6d5076629cba09eb64f5e1269 to your computer and use it in GitHub Desktop.

Select an option

Save bishwahang/636c57b6d5076629cba09eb64f5e1269 to your computer and use it in GitHub Desktop.
user row_number window function in postgres
freeletics_api_dev=# select row_nr, first_name, fl_uid from (select row_number() over (order by fl_uid asc) as row_nr, fl_uid, first_name from users) sub
where sub.first_name = 'nocoach';
row_nr | first_name | fl_uid
--------+------------+--------
2 | nocoach | 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment