Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b3reI-0000MR-MX for pgsql-docs@arkaria.postgresql.org; Fri, 20 May 2016 21:07:58 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1b3reI-0002Tp-9Q for pgsql-docs@arkaria.postgresql.org; Fri, 20 May 2016 21:07:58 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1b3rdw-000246-MT for pgsql-docs@postgresql.org; Fri, 20 May 2016 21:07:36 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1b3rds-0007hD-RV for pgsql-docs@postgresql.org; Fri, 20 May 2016 21:07:36 +0000 Received: from pro.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id u4KL7Sj0008605; Fri, 20 May 2016 17:07:28 -0400 From: Tom Lane To: "David G. Johnston" cc: "pgsql-docs@postgresql.org" Subject: Re: Is this example regarding aggregates sourced by subquery correct? In-reply-to: References: Comments: In-reply-to "David G. Johnston" message dated "Fri, 20 May 2016 16:08:27 -0400" Date: Fri, 20 May 2016 17:07:28 -0400 Message-ID: <55062.1463778448@sss.pgh.pa.us> X-Pg-Spam-Score: -3.3 (---) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-docs Precedence: bulk Sender: pgsql-docs-owner@postgresql.org "David G. Johnston" 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 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 -- Sent via pgsql-docs mailing list (pgsql-docs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-docs