Marko Tiikkaja <marko.tiikkaja@cs.helsinki.fi> writes:
> On 2009-12-15 23:10 +0200, Tom Lane wrote:
>> If we really wanted to take the above seriously, my opinion is that
>> we ought to introduce DISTINCT ON in aggregates.
> FWIW, in my opinion the idea behind this patch is to not fall back on
> hacks like that. This patch already goes beyond the standard and having
> this seems like a useful feature in some cases. Although the DISTINCT
> ON syntax would have a bit more resemblance on the existing syntax, I'd
> still like to see agg(distinct x order by x,y).
I remain entirely unconvinced. If DISTINCT + ORDER BY work differently
inside aggregates than at query level, we're going to forever be
explaining the difference, fielding bug reports, etc. Even documenting
the difference would be a serious PITA considering how subtle it is
(AFAICS Andrew's submitted doc patch failed to address the point).
I'm not against the idea of introducing DISTINCT ON here, though I think
perhaps we ought to wait for a release or so and see if there's really
any field demand for it.
regards, tom lane