>>>>> "Tom" == Tom Lane <tgl@sss.pgh.pa.us> writes:
>> Query-level DISTINCT shouldn't allow columns in the order by that>> aren't in the select list because those columns
_donot exist_ at>> the point that ordering logically takes place (even though in the>> implementation, they might).
>> This isn't the case for aggregate order by.
Tom> I entirely disagree. Why should the semantics of thisTom> combination of ORDER BY and DISTINCT be different from
whattheyTom> are at the query top level? We made other decisions about thisTom> feature on the basis of making the two
caseswork alike, and ITom> don't think you've made an adequate argument for making them actTom> differently.
A case could possibly be made that the behaviour of DISTINCT at top
level is wrong, or at least less useful than need be.
Notice that there are cases where agg(distinct x order by x) is
nondeterministic while agg(distinct x order by x,y) is deterministic.
In my view that alone is a good argument for allowing it.
--
Andrew (irc:RhodiumToad)