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 1oxuQ1-0004u5-IR for pgsql-docs@arkaria.postgresql.org; Wed, 23 Nov 2022 18:24:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oxuQ0-0007kt-6d for pgsql-docs@arkaria.postgresql.org; Wed, 23 Nov 2022 18:24:20 +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 1oxuPz-0007kj-VI for pgsql-docs@lists.postgresql.org; Wed, 23 Nov 2022 18:24:19 +0000 Received: from momjian.us ([72.94.173.45]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oxuPx-0007jx-Gj for pgsql-docs@lists.postgresql.org; Wed, 23 Nov 2022 18:24:18 +0000 Received: from bruce by momjian.us with local (Exim 4.94.2) (envelope-from ) id 1oxuPv-00Aj9w-4g; Wed, 23 Nov 2022 13:24:15 -0500 Date: Wed, 23 Nov 2022 13:24:15 -0500 From: Bruce Momjian To: Tom Lane Cc: jwwfou@gmail.com, pgsql-docs@lists.postgresql.org Subject: Re: Possibly Incorrect Data Return Message-ID: References: <166794307526.652.9073408178177444190@wrigleys.postgresql.org> <3869389.1667946144@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3869389.1667946144@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, Nov 8, 2022 at 05:22:24PM -0500, Tom Lane wrote: > 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! Sorry, that was me, and I thought I checked it, but obviously incorrectly, thanks. -- Bruce Momjian https://momjian.us EDB https://enterprisedb.com Indecision is a decision. Inaction is an action. Mark Batterson