Subject | Re: [firebird-support] RecNo in query |
---|---|
Author | Milan Babuskov |
Post date | 2005-05-25T15:03:35Z |
matijamikac wrote:
1. Use generator. It will only work if you are the only user doing the select
at a time.
2. Use count. Not very optimal though. For example, if query is:
select X from t order by X;
You can write it as:
select X, (select count(*) from t2 where t.X < t2.X),
from t
order by X;
3. Use stored procedure. This would be most efficient way of doing it:
declare variable counter integer;
counter = 0;
for
select a, b, c
from t
into :a, :b, :c
do
begin
counter = counter + 1;
suspend;
end
But, I don't see why you need such feature, you can easily add ordinal numbers
from your application.
--
Milan Babuskov
http://fbexport.sourceforge.net
http://www.flamerobin.org
> How can I create simple SELECT query that will, in addition toYou could:
> standard columns A,B,C give me count number (recno) as one of
> resulting columns?
1. Use generator. It will only work if you are the only user doing the select
at a time.
2. Use count. Not very optimal though. For example, if query is:
select X from t order by X;
You can write it as:
select X, (select count(*) from t2 where t.X < t2.X),
from t
order by X;
3. Use stored procedure. This would be most efficient way of doing it:
declare variable counter integer;
counter = 0;
for
select a, b, c
from t
into :a, :b, :c
do
begin
counter = counter + 1;
suspend;
end
But, I don't see why you need such feature, you can easily add ordinal numbers
from your application.
--
Milan Babuskov
http://fbexport.sourceforge.net
http://www.flamerobin.org