Subject Re: [firebird-support] Serial number in a query result
Author Mike Pomraning
On Thu, Mar 24, 2011 at 2:06 AM, Thomas Steinmaurer <ts@...>wrote:

> > I searched through the net and found MS Sql server has something like
> this
> >
> > select ROW_NUMBER()OVER(ORDERBY ColumnName1) AsSrNo
> >
> > I just want to know whether anything like this is available in firebird.
> Window functions including the OVER clause etc. will be supported in
> Firebird 3. I think the only way to do this currently is to write a
> selectable stored procedure. Perhaps some tricky RDB$GET_CONTEXT /
> RDB$SET_CONTEXT mix can simulate this too.

That trickiness appears in the FAQ: "How to get record number as part of

A throw-away SEQUENCE would also do the trick, I think:

sql> create sequence AdHoc;
sql> select next value for AdHoc as SrNo, d.* FROM (...) d;


[Non-text portions of this message have been removed]