Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fZzlN-0005UQ-Nw for pgsql-general@arkaria.postgresql.org; Mon, 02 Jul 2018 14:25:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fZzlL-0002bw-MG for pgsql-general@arkaria.postgresql.org; Mon, 02 Jul 2018 14:25:07 +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.89) (envelope-from ) id 1fZzlL-0002bp-EY for pgsql-general@lists.postgresql.org; Mon, 02 Jul 2018 14:25:07 +0000 Received: from n3.nabble.com ([162.255.23.22]) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fZzlI-0005FO-9b for pgsql-general@postgresql.org; Mon, 02 Jul 2018 14:25:07 +0000 Received: from n3.nabble.com (localhost [127.0.0.1]) by n3.nabble.com (Postfix) with ESMTP id 098DADCE2410 for ; Mon, 2 Jul 2018 07:25:02 -0700 (MST) Date: Mon, 2 Jul 2018 07:25:01 -0700 (MST) From: pinker To: pgsql-general@postgresql.org Message-ID: <1530541501991-0.post@n3.nabble.com> Subject: except all & WITH - syntax error? MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi! Something strange happened to me right now. I'm trying to compare results from one query with rewritten version and everything is ok with this order: WITH abc AS (SELECT 1) SELECT 1 except all SELECT 1 but when I'm trying other way around it throws an error: SELECT 1 except all WITH abc AS (SELECT 1) SELECT 1 ERROR: syntax error at or near "WITH" LINE 3: WITH abc AS (SELECT 1) SELECT 1 ^ SQL state: 42601 Character: 21 "PostgreSQL 9.6.9 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-16), 64-bit" Is this expected behaviour? It's much harder to optimize queries without this option. -- Sent from: http://www.postgresql-archive.org/PostgreSQL-general-f1843780.html