Re: Possibly Incorrect Data Return

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: jwwfou(at)gmail(dot)com
Cc: pgsql-docs(at)lists(dot)postgresql(dot)org
Subject: Re: Possibly Incorrect Data Return
Date: 2022-11-08 22:22:24
Message-ID: 3869389.1667946144@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs

PG Doc comments form <noreply(at)postgresql(dot)org> 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

In response to

Responses

Browse pgsql-docs by date

  From Date Subject
Next Message Maciek Sakrejda 2022-11-09 05:52:56 Re: Usability ideas: text width and headers that are links
Previous Message Tom Lane 2022-11-08 22:07:25 Re: Example code bug: destination->data