Re: ORDER records based on parameters in IN clause - Mailing list pgsql-sql

From Michael Fuhr
Subject Re: ORDER records based on parameters in IN clause
Date
Msg-id 20050628045700.GA18147@winnie.fuhr.org
Whole thread Raw
In response to ORDER records based on parameters in IN clause  ("Riya Verghese" <riya.verghese@admissioncorp.com>)
List pgsql-sql
On Mon, Jun 27, 2005 at 09:15:15AM -0700, Riya Verghese wrote:
>
> I have a stmt where the outer-query is limited by the results of the
> inner query. I would like the outer query to return records in the same
> order as the values provided in the IN clause (returned form the inner
> query). 

If you want a particular order then use ORDER BY.  The SQL standard
says that without an ORDER BY clause, row order is implementation-
dependent; the PostgreSQL documentation also says the same thing:

http://www.postgresql.org/docs/8.0/static/queries-order.html

"If sorting is not chosen, the rows will be returned in an unspecified
order.  The actual order in that case will depend on the scan and
join plan types and the order on disk, but it must not be relied on.
A particular output ordering can only be guaranteed if the sort step
is explicitly chosen."

-- 
Michael Fuhr
http://www.fuhr.org/~mfuhr/


pgsql-sql by date:

Previous
From: "Sim Zacks"
Date:
Subject: Re: scroll cursor bug or me?
Next
From: "M.D.G. Lange"
Date:
Subject: Re: Unique primary index?