Re: Function for numbering rows? - Mailing list pgsql-sql

From CoL
Subject Re: Function for numbering rows?
Date
Msg-id c5f4n0$l4f$1@news.hub.org
Whole thread Raw
List pgsql-sql
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.


pgsql-sql by date:

Previous
From:
Date:
Subject: ANN: www.SQL-Scripts.Com
Next
From: Jeff Boes
Date:
Subject: Re: SQL challenge--top 10 for each key value?