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 1osX0I-00074R-B1 for pgsql-docs@arkaria.postgresql.org; Tue, 08 Nov 2022 22:23:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1osWzH-0007dg-MO for pgsql-docs@arkaria.postgresql.org; Tue, 08 Nov 2022 22:22:31 +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 1osWzH-0007dG-EZ for pgsql-docs@lists.postgresql.org; Tue, 08 Nov 2022 22:22:31 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1osWzC-0000Mc-FJ for pgsql-docs@lists.postgresql.org; Tue, 08 Nov 2022 22:22:27 +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 2A8MMOu73869390; Tue, 8 Nov 2022 17:22:24 -0500 From: Tom Lane To: jwwfou@gmail.com cc: pgsql-docs@lists.postgresql.org Subject: Re: Possibly Incorrect Data Return In-reply-to: <166794307526.652.9073408178177444190@wrigleys.postgresql.org> References: <166794307526.652.9073408178177444190@wrigleys.postgresql.org> Comments: In-reply-to PG Doc comments form message dated "Tue, 08 Nov 2022 21:31:15 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3869388.1667946144.1@sss.pgh.pa.us> Date: Tue, 08 Nov 2022 17:22:24 -0500 Message-ID: <3869389.1667946144@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk PG Doc comments form writes: > Hello: I am working through the tutorial and the Doc page says the row count > is 5 but my results show 0 records. Of course, I may be doing something > wrong, too: > jwjwj=# SELECT city, max(temp_lo), count(*) FILTER (WHERE temp_lo < 30) > FROM weather > GROUP BY city > HAVING max(temp_lo) < 40; > city | max | count > ---------+-----+------- > Hayward | 37 | 0 > (1 row) No, you're right, given the sample data shown earlier then count = 0 is what you would get. Somebody injected this FILTER example without a lot of thought, it would appear, as not only does the output not match but it's completely disjointed from the flow of explanation (IMO anyway). This example originally introduced only HAVING, and trying to make it do double duty just confuses things. A fully separate example of FILTER would have served better. I'll go do something about that --- thanks for the report! regards, tom lane