pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Generating serial number column
2+ messages / 2 participants
[nested] [flat]

* Generating serial number column
@ 2003-02-13 16:21 Mintoo Lall <tlqmail@yahoo.com>
  2003-02-13 16:40 ` Re: Generating serial number column Gary Stainburn <gary.stainburn@ringways.co.uk>
  0 siblings, 1 reply; 2+ messages in thread

From: Mintoo Lall @ 2003-02-13 16:21 UTC (permalink / raw)
  To: pgsql-sql

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



---------------------------------
Do you Yahoo!?
Yahoo! Shopping - Send Flowers for Valentine's Day

^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Generating serial number column
  2003-02-13 16:21 Generating serial number column Mintoo Lall <tlqmail@yahoo.com>
@ 2003-02-13 16:40 ` Gary Stainburn <gary.stainburn@ringways.co.uk>
  0 siblings, 0 replies; 2+ messages in thread

From: Gary Stainburn @ 2003-02-13 16:40 UTC (permalink / raw)
  To: Mintoo Lall <tlqmail@yahoo.com>; pgsql-sql

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     




^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2003-02-13 16:40 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-02-13 16:21 Generating serial number column Mintoo Lall <tlqmail@yahoo.com>
2003-02-13 16:40 ` Gary Stainburn <gary.stainburn@ringways.co.uk>

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