Re: Preserving order through an inner join

From: Darren Duncan <darren(at)darrenduncan(dot)net>
To: pgsql-general(at)postgresql(dot)org
Cc: Kevin Jardine <kevinjardine(at)yahoo(dot)com>
Subject: Re: Preserving order through an inner join
Date: 2010-09-27 19:04:40
Message-ID: 4CA0EAC8.5080409@darrenduncan.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Gurjeet Singh wrote:
> On Sun, Sep 26, 2010 at 9:37 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> The SQL standard explicitly disavows any particular
> output row order unless there is a top-level ORDER BY. (In fact,
> unless things have changed recently an ORDER BY in a sub-select isn't
> even legal per spec.)
>
> Not sure about the SQL spec allowing it, but an ORDER BY followed by a
> LIMIT does have valid use cases in sub-selects.

Absolutely it does, but that is just a row *filtering* operation. You still
have to have a separate ORDER BY in the outermost query to get result rows
output in a particular order. -- Darren Duncan

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David Boreham 2010-09-27 21:07:24 zero_damaged_pages doesn't work
Previous Message Darren Duncan 2010-09-27 19:00:44 Re: Preserving order through an inner join