Be carful using RANK if the primary index of the table is not unique. RANK give the same rank to identical values:
INDEX RANK
a 1
b 2
b 2
c 4
You can also use CSUM(1,1) to add an ordered sequence to the rows without duplicates.
Select field1, field2, CSUM(1,1)
from db1
order by 1