Thread: Re: Function for numbering rows?

Re: Function for numbering rows?

From
CoL
Date:
hi,

Tony Reina wrote, On 4/10/2004 18:12:

> Simple question:
> 
> Is there a function that will allow me to number the returned tuples?
> 
> e.g. 
> 
> CREATE TABLE test (
> field1 text
> ):
> 
> INSERT INTO test VALUES ('first');
> INSERT INTO test VALUES ('second');
> INSERT INTO test VALUES ('third');
> INSERT INTO test VALUES ('fourth');
> 
> SELECT number(), field1 FROM test;
> 
> 1  'first'
> 2  'second'
> 3  'third'
> 4  'fourth'
> 
> where number() is the function I'm trying to find out about.
a simple way:
create temporary sequence st;
select nextval('st'),field1 from test;
drop sequence st;

C.