Peter Eisentraut <peter_e@gmx.net> writes:
> How else will you tell an aggregate function whose result depends on the
> input order which order you want?
You feed it from a subquery that has ORDER BY. The only reason the spec
needs this kluge is their insistence that ORDER BY not be used in
subqueries. Now I grant that there's some basis in relational theory
for that stand, but they certainly feel free to ignore academic notions
of cleanliness everywhere else in the spec.
regards, tom lane