Re: why the difference? - Mailing list pgsql-sql

From Tom Lane
Subject Re: why the difference?
Date
Msg-id 11686.1037890040@sss.pgh.pa.us
Whole thread Raw
In response to Re: why the difference?  (Jakub Ouhrabka <jouh8664@ss1000.ms.mff.cuni.cz>)
List pgsql-sql
Jakub Ouhrabka <jouh8664@ss1000.ms.mff.cuni.cz> writes:
> the where clause is evaluated before the distinct clause, so your queries
> aren't equivalent because you switched the order by splitting the query
> into two queries...

Besides which, SELECT DISTINCT ON is order-sensitive.  If you don't use
an ORDER BY with it, you are going to get rather unpredictable results.
See the example on the SELECT reference page.
        regards, tom lane


pgsql-sql by date:

Previous
From: "Peter Galbavy"
Date:
Subject: help optimise this ?
Next
From: "Henshall, Stuart - Design & Print"
Date:
Subject: Re: help optimise this ?