Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vvNcj-00GWfG-1W for pgsql-general@arkaria.postgresql.org; Wed, 25 Feb 2026 22:44:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vvNch-008qgd-0Z for pgsql-general@arkaria.postgresql.org; Wed, 25 Feb 2026 22:44:51 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vvNcg-008qgU-2j for pgsql-general@lists.postgresql.org; Wed, 25 Feb 2026 22:44:50 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1vvNcc-00000001I3J-3mlz for pgsql-general@lists.postgresql.org; Wed, 25 Feb 2026 22:44:50 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 61PMihDW532252; Wed, 25 Feb 2026 17:44:43 -0500 From: Tom Lane To: "David G. Johnston" cc: Adrian Klaver , PALAYRET Jacques , pgsql-general@lists.postgresql.org Subject: Re: PostgreSQL query with FULL OUTER JOIN and subquery using column of GROUP BY expression ERROR: subquery uses ungrouped column from outer query In-reply-to: <295608.1772040819@sss.pgh.pa.us> References: <970600119.344834366.1772018068349.JavaMail.zimbra@meteo.fr> <52acd108-2949-4762-80c2-c761662fde73@aklaver.com> <295608.1772040819@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Wed, 25 Feb 2026 12:33:39 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <532250.1772059483.1@sss.pgh.pa.us> Date: Wed, 25 Feb 2026 17:44:43 -0500 Message-ID: <532251.1772059483@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk I wrote: > "David G. Johnston" writes: >> My first impression is that this is a bug. Especially since the query >> apparently executes in both left-join and right-join modes. > Well, it's a longstanding deficiency anyway. > ... > Still, it is annoying. I wonder if there's a way to do it without > either a large amount of new code or exponential time spent > trying useless subexpression matches... I've posted a draft fix for that at https://www.postgresql.org/message-id/flat/531183.1772058731%40sss.pgh.pa.us regards, tom lane