From: Gary Stainburn <gary.stainburn@ringways.co.uk>
To: Mintoo Lall <tlqmail@yahoo.com>
To: pgsql-sql@postgresql.org
Subject: Re: Generating serial number column
Date: Thu, 13 Feb 2003 16:40:46 +0000
Message-ID: <200302131640.46853.gary.stainburn@ringways.co.uk> (raw)
In-Reply-To: <20030213162156.26511.qmail@web14805.mail.yahoo.com>
References: <20030213162156.26511.qmail@web14805.mail.yahoo.com>
On Thursday 13 Feb 2003 4:21 pm, Mintoo Lall wrote:
> Hi Everybody ,
>
> Is there a way in postgresql by which I can generate serial number column
> for the resultset. I wanted the resulset to look like below
>
>
> sno Name
> -------------------
> 1 JOE
> 2 JOHN
> 3 MARY
> 4 LISA
> 5 ANN
> 6 BILL
> 7 JACK
> 8 WILL
> 9 GEORGE
> 10 NANCY
> 11 JANE
> . .
> . .
> . .
>
> My query is basically select * name from tblcontact. I wanted to generate
> the column "sno" which basically numbers each row returned. Any help is
> appreciated.
> Regards,
> Tarun
create sequence myseq;
select nextval('myseq'), name from tblcontact;
drop sequence myseq;
There may well be a way to do it without the sequence, bit I can't think of
one.
Gary
>
>
>
> ---------------------------------
> Do you Yahoo!?
> Yahoo! Shopping - Send Flowers for Valentine's Day
--
Gary Stainburn
This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000
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: gary.stainburn@ringways.co.uk, tlqmail@yahoo.com
Subject: Re: Generating serial number column
In-Reply-To: <200302131640.46853.gary.stainburn@ringways.co.uk>
* 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