Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id BDAA84763F7 for ; Tue, 17 Sep 2002 10:14:55 -0400 (EDT) Received: from mail.astrofoto.org (dsl092-102-177.nyc2.dsl.speakeasy.net [66.92.102.177]) by postgresql.org (Postfix) with ESMTP id 11C4D4763EA for ; Tue, 17 Sep 2002 10:14:55 -0400 (EDT) Received: from kuiper.rlent.pnet (IDENT:root@kuiper.rlent.pnet [192.168.3.50]) by mail.astrofoto.org (8.12.3/8.12.3) with ESMTP id g8HEExtV004570 for ; Tue, 17 Sep 2002 10:14:59 -0400 Received: (from roland@localhost) by kuiper.rlent.pnet (8.11.6/8.11.6) id g8HEEwc02519; Tue, 17 Sep 2002 10:14:58 -0400 X-Authentication-Warning: kuiper.rlent.pnet: roland set sender to roland@astrofoto.org using -f To: Subject: Re: How to select and result row number?? References: <001301c25b5a$2ef0ea40$8a01a8c0@yudie> From: Roland Roberts Date: 17 Sep 2002 10:14:58 -0400 In-Reply-To: <001301c25b5a$2ef0ea40$8a01a8c0@yudie> Message-ID: Lines: 30 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2.90 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200209/191 X-Sequence-Number: 9468 >>>>> "Yudie" == Yudie writes: Yudie> what is the select statement so I can get result records like this Yudie> no cityname Yudie> ---- -------------- Yudie> 1 NEW YORK Yudie> 2 LOS ANGELES Yudie> 3 HOUSTON Yudie> 4 .... Yudie> 5 ... This is not really a SQL type result; you are probably better of writing something in a procedural language. That said, something like this seems to work for 7.2: create sequence temp_counter; select nextval('temp_counter'), * from whatever; If you have an 'order by', the above will not work. You could then try either building a temporary table or using a subselect select nextval('temp_counter'), * from (select .... order by ...); roland -- PGP Key ID: 66 BC 3B CD Roland B. Roberts, PhD RL Enterprises roland@rlenter.com 76-15 113th Street, Apt 3B roland@astrofoto.org Forest Hills, NY 11375