Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nWdwB-0007f1-ER for pgsql-general@arkaria.postgresql.org; Tue, 22 Mar 2022 12:48:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nWdwA-0005ZC-9X for pgsql-general@arkaria.postgresql.org; Tue, 22 Mar 2022 12:48:34 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nWdw9-0005Z3-Lo for pgsql-general@lists.postgresql.org; Tue, 22 Mar 2022 12:48:33 +0000 Received: from smtp-zimbra.meteo.fr ([137.129.16.22] helo=celebrian2.meteo.fr) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nWdw0-0006Qz-Nw for pgsql-general@postgresql.org; Tue, 22 Mar 2022 12:48:32 +0000 Received: from localhost (localhost [127.0.0.1]) by celebrian2.meteo.fr (Postfix) with ESMTP id 0EB5F48097 for ; Tue, 22 Mar 2022 13:48:23 +0100 (CET) Received: from celebrian2.meteo.fr ([127.0.0.1]) by localhost (celebrian2.meteo.fr [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id jUbXucDoStRp for ; Tue, 22 Mar 2022 13:48:22 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by celebrian2.meteo.fr (Postfix) with ESMTP id E2C084814D for ; Tue, 22 Mar 2022 13:48:22 +0100 (CET) X-Virus-Scanned: amavisd-new at celebrian2.meteo.fr Received: from celebrian2.meteo.fr ([127.0.0.1]) by localhost (celebrian2.meteo.fr [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 09ogNZbFwmOM for ; Tue, 22 Mar 2022 13:48:22 +0100 (CET) Received: from zumba5.meteo.fr (zumba5 [172.31.9.201]) by celebrian2.meteo.fr (Postfix) with ESMTP id B762648097 for ; Tue, 22 Mar 2022 13:48:22 +0100 (CET) Date: Tue, 22 Mar 2022 13:48:21 +0100 (CET) From: PALAYRET Jacques To: PostgreSQL mailing lists Message-ID: <812470944.47219637.1647953301941.JavaMail.zimbra@meteo.fr> In-Reply-To: References: <1370619684.47054020.1647942355596.JavaMail.zimbra@meteo.fr> Subject: Re: PostgreSQL : bug (ou not) in CTE Common Table Expressions or Subqueries in the FROM Clause MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="=_728e8eb2-38b8-4c2c-999b-65aaee12594a" X-Originating-IP: [172.31.9.205] X-Mailer: Zimbra 8.7.11_GA_3822 (ZimbraWebClient - FF91 (Win)/8.7.11_GA_3822) Thread-Topic: PostgreSQL : bug (ou not) in CTE Common Table Expressions or Subqueries in the FROM Clause Thread-Index: jJ2Iti+PoKKiCCQmuIe6VC4M+v1zmg== List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --=_728e8eb2-38b8-4c2c-999b-65aaee12594a Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Thanks a lot.=20 Visibly, you are right.=20 It's a correlated statement, OK, right.=20 But in the subquery :=20 (=20 SELECT x.elev=20 FROM elev_Tlse_Blagnac AS x=20 WHERE w.id BETWEEN 31000000 and 31999999=20 )=20 the WHERE clause (=3D w.id BETWEEN 31000000 and 31999999) is for the SELECT= x.elev FROM elev_Tlse_Blagnac=20 which is the value 151 (one line, one value), correlation or not.=20 So, for me, it should NOT be a WHERE clause (a condition) for the MAIN stat= ement.=20 According to me, there is only one condition in the main statement (SELECT = w.id, w.name, w.elev FROM weather_stations ...)=20 and it is : elev > 151 (correlation ou not correlation).=20 In others words : for each line of table weather_stations), the only condit= ion is : is the elev superior than the elev returned by the subquery, 151 ?= =20 Visibly, the correlated statement adds one condition (w.id BETWEEN 31000000= and 31999999) in the main statement, but it's not logical for me, because = of the parentheses.=20