X-Original-To: pgsql-sql@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id A707F474E4F for ; Thu, 13 Feb 2003 11:43:13 -0500 (EST) Received: from stan.ringways.co.uk (hub.ringways.co.uk [213.38.87.130]) by postgresql.org (Postfix) with ESMTP id 0E937474E42 for ; Thu, 13 Feb 2003 11:43:13 -0500 (EST) Received: from gary.ringways.co.uk ([10.1.1.2]) by stan.ringways.co.uk with esmtp (Exim 3.22 #1) id 18jMQj-0000Zc-00; Thu, 13 Feb 2003 16:41:45 +0000 Content-Type: text/plain; charset="iso-8859-1" From: Gary Stainburn Organization: Ringways Garages Ltd To: Mintoo Lall , pgsql-sql@postgresql.org Subject: Re: Generating serial number column Date: Thu, 13 Feb 2003 16:40:46 +0000 User-Agent: KMail/1.4.3 References: <20030213162156.26511.qmail@web14805.mail.yahoo.com> In-Reply-To: <20030213162156.26511.qmail@web14805.mail.yahoo.com> MIME-Version: 1.0 Message-Id: <200302131640.46853.gary.stainburn@ringways.co.uk> Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200302/289 X-Sequence-Number: 11687 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= =20 one. Gary > > > > --------------------------------- > Do you Yahoo!? > Yahoo! Shopping - Send Flowers for Valentine's Day --=20 Gary Stainburn =20 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=20= =20=20=20=20