From: CoL <col@mportal.hu>
To: pgsql-sql@postgresql.org
Subject: Re: Function for numbering rows?
Date: Tue, 13 Apr 2004 00:21:01 +0200
Message-ID: <c5f4n0$l4f$1@news.hub.org> (raw)
In-Reply-To: <272e4be7.0404100812.50a8c7fe@posting.google.com>
References: <272e4be7.0404100812.50a8c7fe@posting.google.com>
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.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: col@mportal.hu
Subject: Re: Function for numbering rows?
In-Reply-To: <c5f4n0$l4f$1@news.hub.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox