Обсуждение: Generating serial number column
Hi Everybody ,<br /><br />Is there a way in postgresql by which I can generate serial number column for the<br />resultset.I wanted the resulset to look like below<br /><br /><br />sno Name<br />-------------------<br />1 JOE<br />2 JOHN<br />3 MARY<br />4 LISA<br />5 ANN<br />6 BILL<br />7 JACK<br />8 &nb sp; WILL<br />9 GEORGE<br />10 NANCY<br />11 JANE<br /> . .<br /> . .<br /> . .<br /><br />My query is basically select * name from tblcontact. I wantedto generate<br />the column "sno" which basically numbers each row returned. Any help is<br />appreciated.<br />Regards,<br/>Tarun<br /><p><br /><hr size="1" />Do you Yahoo!?<br /><a href="http://rd.yahoo.com/O=1/I=brandr/vday03/text/flow/*http://shopping.yahoo.com /shop?d=browse&id=20146735">Yahoo! Shopping</a> - Send Flowers for Valentine's Day
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
How do you do a table Pivot in PostgreSQL? tia, .V =====