Subject Re: [firebird-support] Record numbering
Author Svein Erling Tysvaer
With a set ordered by a unique field, this can be done as

select (select count(*) + 1 from MyTable M2 where M2.Somefield <
M1.Somefield) as RecNo, M1.Somefield
from MyTable M1
Order by M1.Somefield

Though it doesn't work on any unordered dataset and doing it on a client
or through a stored procedure is a much better solution (though the
above solution is quite funny and should work).


jasajona wrote:
> How to write select that gives field of selected record number. I have
> table just from one field "SomeField" how to get result:
> RecNo SomeField
> ----- --------------
> 1 sdferfer
> 2 ertertt dfgdfg
> 3 df ;dlfklee
> ...
> I do not want to use generators, I need every time to start from 1