The following documentation comment has been logged on the website:

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

city   | max | count
---------+-----+-------
 Hayward |  37 |     5
(1 row)
it's not right

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 |  35 |     0

because
SELECT city, max(temp_lo), count(*) FILTER (WHERE temp_lo < 30)
    FROM weather
    WHERE city LIKE 'S%'            -- (1)
    GROUP BY city
    HAVING max(temp_lo) < 40;
 city | max | count
------+-----+-------
(0 rows)

Reply via email to