>>>>> "Tom" == Tom Lane <tgl@sss.pgh.pa.us> writes:
Tom> Another thing to think about here is to wonder why the committee choseTom> anything as verbose as "agg(...) WITHIN
GROUP(ORDER BY ...)" in theTom> first place. The words ORDER BY certainly seem pretty unnecessary.
All of the ordered-set functions that the spec defines are intimately tied
to ordering of values, and they allow things like DESC ordering to affect
the results, so it seems obvious to me that they used (ORDER BY ...) because
what follows is both syntactically and semantically similar to any other use
of ORDER BY. (Similar logic seems to have been used for "FILTER (WHERE ...)".)
(The name "ordered set function" also seems quite specific.)
So I don't think there's any greater chance of the spec people adding
a WITHIN GROUP (something_other_than_order_by) construct than of them
adding any other awkward piece of syntax - and if they did, it would
represent an entirely new class of aggregate functions, separate from
ordered set functions and no doubt with its own headaches.
(I realize that expecting sanity from the spec writers is perhaps unwise)
--
Andrew (irc:RhodiumToad)