Andrew Gierth <and...@tao11.riddles.org.uk> writes: > "Tom" == Tom Lane <t...@sss.pgh.pa.us> writes: > Tom> Actually, now that I think of it, why not use this syntax for > Tom> declaration and display purposes: > Tom> type1, type2 ORDER BY type3, type4
> But unfortunately it looks exactly like the calling sequence for a > normal aggregate with an order by clause - I really think that is > potentially too much confusion. I thought about that too, but really that ship sailed long ago, and it went to sea under the SQL committee's captaincy, so it's not our fault. There are already at least four different standards-blessed ways you can use ORDER BY in a query, some of them quite nearby (eg window functions); so the potential for confusion is there no matter what we do. In this case, if we describe ordered-set aggregates using WITHIN GROUP rather than ORDER BY, we might avoid confusion with the normal-aggregate case, but instead we will have confusion about what the arguments even do. Is semantic confusion better than syntactic confusion? Another thing to think about here is to wonder why the committee chose anything as verbose as "agg(...) WITHIN GROUP (ORDER BY ...)" in the first place. The words ORDER BY certainly seem pretty unnecessary. I'm suspicious that they might've been leaving the door open to put other things into the second set of parens later --- GROUP BY, maybe? So down the road, we might regret it if we key off WITHIN GROUP and not ORDER BY. Having said that, I'm not so dead set on it that I won't take WITHIN GROUP if that's what more people want. But we gotta lose the extra parens; they are just too strange for function declaration/documentation purposes. regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers