4.2.7. Aggregate Expressions

Started by PG Bug reporting form3 months ago4 messagesdocs
Jump to latest
#1PG Bug reporting form
noreply@postgresql.org

The following documentation comment has been logged on the website:

Page: https://www.postgresql.org/docs/18/sql-expressions.html
Description:

Can you add a code block with an example?

Perhaps something like this:

```psql
db=# WITH vals (f1) AS ( VALUES (1),(3),(4),(3),(2),(null) )
SELECT count(*), count(f1), COUNT(DISTINCT f1) FROM vals;

count | count | count
-------+-------+-------
6 | 5 | 4
(1 row)
```

After:

For example, count(*) returns the total number of input rows; count(f1)

returns the number of input rows in which f1 is not null, since count
ignores null values; and count(distinct f1) returns the number of distinct
non-null values of f1.

We haven’t seen the term “f1” before—and the paragraph doesn’t specify that
this is a field.

#2Bruce Momjian
bruce@momjian.us
In reply to: PG Bug reporting form (#1)
Re: 4.2.7. Aggregate Expressions

On Thu, Aug 27, 2026 at 02:26:46PM +0000, PG Doc comments form wrote:

The following documentation comment has been logged on the website:

Page: https://www.postgresql.org/docs/18/sql-expressions.html
Description:

Can you add a code block with an example?

Perhaps something like this:

```psql
db=# WITH vals (f1) AS ( VALUES (1),(3),(4),(3),(2),(null) )
SELECT count(*), count(f1), COUNT(DISTINCT f1) FROM vals;

count | count | count
-------+-------+-------
6 | 5 | 4
(1 row)
```

After:

For example, count(*) returns the total number of input rows; count(f1)

returns the number of input rows in which f1 is not null, since count
ignores null values; and count(distinct f1) returns the number of distinct
non-null values of f1.

I see your point that this could be clearer. How is this patch?

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

Do not let urgent matters crowd out time for investment in the future.

Attachments:

t253648_2
agg_null.difftext/x-diff; charset=us-asciiDownload+13-5
#3Laurenz Albe
laurenz.albe@cybertec.at
In reply to: Bruce Momjian (#2)
Re: 4.2.7. Aggregate Expressions

On Tue, 2026-09-15 at 17:28 -0400, Bruce Momjian wrote:

I see your point that this could be clearer. How is this patch?

I think that is a good example.
+1 for that change.

Yours,
Laurenz Albe

#4Bruce Momjian
bruce@momjian.us
In reply to: Laurenz Albe (#3)
Re: 4.2.7. Aggregate Expressions

On Wed, Sep 16, 2026 at 07:20:56AM +0200, Laurenz Albe wrote:

On Tue, 2026-09-15 at 17:28 -0400, Bruce Momjian wrote:

I see your point that this could be clearer. How is this patch?

I think that is a good example.
+1 for that change.

Great, patch applied back to PG 19.

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

Do not let urgent matters crowd out time for investment in the future.