select row_number() over (order by <field> nulls last) as rownum, *
from foo_tbl
order by <field>
注文が不要な場合は、この回答も簡略化できます:
select row_number() over(), * -- notice: no fields are needed
from foo_tbl
SQLフィドルの概念実証
select row_number() over (order by <field> nulls last) as rownum, *
from foo_tbl
order by <field>
注文が不要な場合は、この回答も簡略化できます:
select row_number() over(), * -- notice: no fields are needed
from foo_tbl
SQLフィドルの概念実証