Re: Function for numbering rows?

From: CoL <col(at)mportal(dot)hu>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: Function for numbering rows?
Date: 2004-04-12 22:21:01
Message-ID: c5f4n0$l4f$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

Browse pgsql-sql by date

  From Date Subject
Next Message Greg Stark 2004-04-13 06:20:00 Re: trigger/for key help
Previous Message Bret Hughes 2004-04-12 07:18:35 Re: trigger/for key help