pg.ddx.io  pgsql-docs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Possibly Incorrect Data Return
3+ messages / 3 participants
[nested] [flat]

* Possibly Incorrect Data Return
@ 2022-11-08 21:31  PG Doc comments form <noreply@postgresql.org>
  0 siblings, 1 reply; 3+ messages in thread

From: PG Doc comments form @ 2022-11-08 21:31 UTC (permalink / raw)
  To: pgsql-docs@lists.postgresql.org; +Cc: jwwfou@gmail.com

The following documentation comment has been logged on the website:

Page: https://www.postgresql.org/docs/15/tutorial-agg.html
Description:

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)


^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Possibly Incorrect Data Return
@ 2022-11-08 22:22  Tom Lane <tgl@sss.pgh.pa.us>
  parent: PG Doc comments form <noreply@postgresql.org>
  0 siblings, 1 reply; 3+ messages in thread

From: Tom Lane @ 2022-11-08 22:22 UTC (permalink / raw)
  To: jwwfou@gmail.com; +Cc: pgsql-docs@lists.postgresql.org

PG Doc comments form <noreply@postgresql.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





^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Possibly Incorrect Data Return
@ 2022-11-23 18:24  Bruce Momjian <bruce@momjian.us>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 3+ messages in thread

From: Bruce Momjian @ 2022-11-23 18:24 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: jwwfou@gmail.com; pgsql-docs@lists.postgresql.org

On Tue, Nov  8, 2022 at 05:22:24PM -0500, Tom Lane wrote:
> PG Doc comments form <noreply@postgresql.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!

Sorry, that was me, and I thought I checked it, but obviously
incorrectly, thanks.

-- 
  Bruce Momjian  <bruce@momjian.us>        https://momjian.us
  EDB                                      https://enterprisedb.com

  Indecision is a decision.  Inaction is an action.  Mark Batterson






^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2022-11-23 18:24 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-11-08 21:31 Possibly Incorrect Data Return PG Doc comments form <noreply@postgresql.org>
2022-11-08 22:22 ` Tom Lane <tgl@sss.pgh.pa.us>
2022-11-23 18:24   ` Bruce Momjian <bruce@momjian.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox