Re: Is this example regarding aggregates sourced by subquery correct?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: "pgsql-docs(at)postgresql(dot)org" <pgsql-docs(at)postgresql(dot)org>
Subject: Re: Is this example regarding aggregates sourced by subquery correct?
Date: 2016-05-20 21:07:28
Message-ID: 55062.1463778448@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs

"David G. Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> writes:
> http://www.postgresql.org/docs/9.5/static/functions-aggregate.html
> """
> SELECT xmlagg(x) FROM (SELECT x FROM test ORDER BY y DESC) AS tab;
> But this syntax is not allowed in the SQL standard, and is not portable to
> other database systems.
> """

> The example seems expressly permitted by the standard and other database
> systems.

The example is illegal in SQL:2003 and before; they did not allow ORDER BY
in a <query expression> until SQL:2008. Even in newer spec versions, it's
considered an optional feature (cf F850-F855). Given that, I would be
pretty leery of claims that it's supported in all other DBMSes. We should
perhaps back off the wording to something like "is not allowed in older
versions of the SQL standard, and may not be portable to other database
systems".

regards, tom lane

In response to

Responses

Browse pgsql-docs by date

  From Date Subject
Next Message David G. Johnston 2016-05-20 22:41:33 Re: Is this example regarding aggregates sourced by subquery correct?
Previous Message David G. Johnston 2016-05-20 20:08:27 Is this example regarding aggregates sourced by subquery correct?