Re: How to select and result row number?? - Mailing list pgsql-sql

From Bruce Momjian
Subject Re: How to select and result row number??
Date
Msg-id 200209172221.g8HMLH227467@candle.pha.pa.us
Whole thread Raw
In response to Re: How to select and result row number??  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: How to select and result row number??  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-sql
Tom Lane wrote:
> Bruce Momjian <pgman@candle.pha.pa.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.

When you specify a table in FROM, there is no ordering to the table.  Is
it guaranteed that a subquery in FROM _does_ have an ordering.   Does
ANSI say it has an ordering?  What if the subquery is involved in a
join?

--  Bruce Momjian                        |  http://candle.pha.pa.us pgman@candle.pha.pa.us               |  (610)
359-1001+  If your life is a hard drive,     |  13 Roberts Road +  Christ can be your backup.        |  Newtown Square,
Pennsylvania19073
 


pgsql-sql by date:

Previous
From: Tom Lane
Date:
Subject: Re: How to select and result row number??
Next
From: Tom Lane
Date:
Subject: Re: cannot delete bug