select row_number() over (order by <field> nulls last) as rownum, *
from foo_tbl
order by <field>
Hvis bestilling ikke er nødvendig, kan dette svar også forenkles:
select row_number() over(), * -- notice: no fields are needed
from foo_tbl
SQL Fiddle Proof of Concept