Subject Re: RecNo in query
Author Svein Erling Tysvær
--- In firebird-support@yahoogroups.com, "matijamikac" wrote:
> How can I create simple SELECT query that will, in addition to
> standard columns A,B,C give me count number (recno) as one of
> resulting columns?

In a stored procedure, no problem

In a query, no way

This isn't quite true, suppose column A was a unique index or a
primary key, then you could do:

select A, B, C,
(select count(*) from MyTable MT2 where MT.A2 <= MT.A) as RecNo
from MyTable MT
order by A

On larger result sets, I think this would be slow. If there is nothing
unique in the result set, then I guess you could achieve the same
thing using rdb$dbkey (see http://www.cvalde
net/document/mysteriousDbKey.htm), but I've never tried.

Don't give up just yet, maybe someone else knows a simpler way not
involving a stored procedure.

HTH,
Set