Re: How to select and result row number??

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: "Ross J(dot) Reedstrom" <reedstrm(at)rice(dot)edu>, Roland Roberts <roland(at)astrofoto(dot)org>, Yudie <yudie(at)axiontech(dot)com>, pgsql-sql(at)postgresql(dot)org
Subject: Re: How to select and result row number??
Date: 2002-09-17 22:13:16
Message-ID: 8957.1032300796@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> 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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Bruce Momjian 2002-09-17 22:21:17 Re: How to select and result row number??
Previous Message Bruce Momjian 2002-09-17 21:44:53 Re: How to select and result row number??