select row_number() over (order by <field> nulls last) as rownum, *
from foo_tbl
order by <field>
Jika urutan tidak diperlukan, jawaban ini juga dapat disederhanakan:
select row_number() over(), * -- notice: no fields are needed
from foo_tbl
Bukti Konsep SQL Fiddle