"how to show row numbers in postgresql query?" Code Answer

select   row_number() over (order by <field> nulls last) as rownum, *
from     foo_tbl
order by <field>

if order is not necessary, this answer may also be simplified:

select row_number() over(), *  -- notice: no fields are needed
from   foo_tbl

sql fiddle proof of concept

By Craig Beaumont on August 18 2022

Answers related to “how to show row numbers in postgresql query?”

Only authorized users can answer the Search term. Please sign in first, or register a free account.