Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 4D537476780 for ; Tue, 17 Sep 2002 18:16:22 -0400 (EDT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id B63384767C3 for ; Tue, 17 Sep 2002 18:16:21 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.5/8.12.5) with ESMTP id g8HMDG5D008958; Tue, 17 Sep 2002 18:13:16 -0400 (EDT) To: Bruce Momjian Cc: "Ross J. Reedstrom" , Roland Roberts , Yudie , pgsql-sql@postgresql.org Subject: Re: How to select and result row number?? In-reply-to: <200209172144.g8HLisd23301@candle.pha.pa.us> References: <200209172144.g8HLisd23301@candle.pha.pa.us> Comments: In-reply-to Bruce Momjian message dated "Tue, 17 Sep 2002 17:44:53 -0400" Date: Tue, 17 Sep 2002 18:13:16 -0400 Message-ID: <8957.1032300796@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200209/198 X-Sequence-Number: 9475 Bruce Momjian writes: >>> select nextval('temp_counter'), * from (select .... order by ...); >> >> Approximately the same solution, but without saving the result in a temp >> table. > I thought about doing it this way. However, a subselect as a > pseudotable is not guaranteed to return the data in any specific order, > so I don't think this method work work reliably. Say what? Given the ORDER BY in the subselect, it will. Of course, you can't do any grouping or other processing at the outer level, but the example as given is just fine. regards, tom lane