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