pg.ddx.io  pgsql-docs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
4.2.7. Aggregate Expressions
4+ messages / 3 participants
[nested] [flat]

* 4.2.7. Aggregate Expressions
@ 2026-08-27 14:26 PG Doc comments form <noreply@postgresql.org>
  2026-09-15 21:28 ` Re: 4.2.7. Aggregate Expressions Bruce Momjian <bruce@momjian.us>
  0 siblings, 1 reply; 4+ messages in thread

From: PG Doc comments form @ 2026-08-27 14:26 UTC (permalink / raw)
  To: pgsql-docs@lists.postgresql.org; +Cc: y.saburov@gmail.com

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.







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

* Re: 4.2.7. Aggregate Expressions
  2026-08-27 14:26 4.2.7. Aggregate Expressions PG Doc comments form <noreply@postgresql.org>
@ 2026-09-15 21:28 ` Bruce Momjian <bruce@momjian.us>
  2026-09-16 05:20   ` Re: 4.2.7. Aggregate Expressions Laurenz Albe <laurenz.albe@cybertec.at>
  0 siblings, 1 reply; 4+ messages in thread

From: Bruce Momjian @ 2026-09-15 21:28 UTC (permalink / raw)
  To: y.saburov@gmail.com; pgsql-docs@lists.postgresql.org

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:

  [text/x-diff] agg_null.diff (1.2K, ../../aqm4f5EZUdcSKh1C@momjian.us/2-agg_null.diff)
  download | inline diff:
diff --git a/doc/src/sgml/syntax.sgml b/doc/src/sgml/syntax.sgml
index 67482996861..a697218c8b3 100644
--- a/doc/src/sgml/syntax.sgml
+++ b/doc/src/sgml/syntax.sgml
@@ -1602,11 +1602,19 @@ sqrt(2)
    </para>
 
    <para>
-    For example, <literal>count(*)</literal> yields the total number
-    of input rows; <literal>count(f1)</literal> yields the number of
-    input rows in which <literal>f1</literal> is non-null, since
-    <function>count</function> ignores nulls; and
-    <literal>count(distinct f1)</literal> yields the number of
+    For example, in this query:
+<programlisting>
+WITH vals (f1) AS ( VALUES (1),(3),(4),(3),(2),(null) )
+SELECT count(*) AS total, count(f1) AS non_null, COUNT(DISTINCT f1) AS distinct
+FROM vals;
+ total | non_null | distinct
+-------+----------+----------
+     6 |        5 |        4
+</programlisting>
+    <literal>total</literal> yields the total number of input rows;
+    <literal>non_null</literal> yields the number of input rows in which
+    <literal>f1</literal> is non-null, since <function>count</function>
+    ignores nulls; and <literal>distinct</literal> yields the number of
     distinct non-null values of <literal>f1</literal>.
    </para>
 

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

* Re: 4.2.7. Aggregate Expressions
  2026-08-27 14:26 4.2.7. Aggregate Expressions PG Doc comments form <noreply@postgresql.org>
  2026-09-15 21:28 ` Re: 4.2.7. Aggregate Expressions Bruce Momjian <bruce@momjian.us>
@ 2026-09-16 05:20   ` Laurenz Albe <laurenz.albe@cybertec.at>
  2026-10-10 02:14     ` Re: 4.2.7. Aggregate Expressions Bruce Momjian <bruce@momjian.us>
  0 siblings, 1 reply; 4+ messages in thread

From: Laurenz Albe @ 2026-09-16 05:20 UTC (permalink / raw)
  To: Bruce Momjian <bruce@momjian.us>; y.saburov@gmail.com; pgsql-docs@lists.postgresql.org

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






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

* Re: 4.2.7. Aggregate Expressions
  2026-08-27 14:26 4.2.7. Aggregate Expressions PG Doc comments form <noreply@postgresql.org>
  2026-09-15 21:28 ` Re: 4.2.7. Aggregate Expressions Bruce Momjian <bruce@momjian.us>
  2026-09-16 05:20   ` Re: 4.2.7. Aggregate Expressions Laurenz Albe <laurenz.albe@cybertec.at>
@ 2026-10-10 02:14     ` Bruce Momjian <bruce@momjian.us>
  0 siblings, 0 replies; 4+ messages in thread

From: Bruce Momjian @ 2026-10-10 02:14 UTC (permalink / raw)
  To: Laurenz Albe <laurenz.albe@cybertec.at>; +Cc: y.saburov@gmail.com; pgsql-docs@lists.postgresql.org

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.






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


end of thread, other threads:[~2026-10-10 02:14 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-08-27 14:26 4.2.7. Aggregate Expressions PG Doc comments form <noreply@postgresql.org>
2026-09-15 21:28 ` Bruce Momjian <bruce@momjian.us>
2026-09-16 05:20   ` Laurenz Albe <laurenz.albe@cybertec.at>
2026-10-10 02:14     ` 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