Skip to content

Commit 2107607

Browse files
committed
Clarify documentation of handling of null arguments for aggregates.
Per discussion.
1 parent 4ff6856 commit 2107607

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

doc/src/sgml/func.sgml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.530 2010/08/24 06:30:43 itagaki Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.531 2010/09/01 18:22:29 tgl Exp $ -->
22

33
<chapter id="functions">
44
<title>Functions and Operators</title>
@@ -10034,7 +10034,7 @@ SELECT NULLIF(value, '(none)') ...
1003410034
<entry>
1003510035
array of the argument type
1003610036
</entry>
10037-
<entry>input values concatenated into an array</entry>
10037+
<entry>input values, including nulls, concatenated into an array</entry>
1003810038
</row>
1003910039

1004010040
<row>

doc/src/sgml/syntax.sgml

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/syntax.sgml,v 1.153 2010/08/13 01:12:38 rhaas Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/syntax.sgml,v 1.154 2010/09/01 18:22:29 tgl Exp $ -->
22

33
<chapter id="sql-syntax">
44
<title>SQL Syntax</title>
@@ -1541,23 +1541,29 @@ sqrt(2)
15411541

15421542
<para>
15431543
The first form of aggregate expression invokes the aggregate
1544-
across all input rows for which the given expression(s) yield
1545-
non-null values. (Actually, it is up to the aggregate function
1546-
whether to ignore null values or not &mdash; but all the standard ones do.)
1544+
once for each input row.
15471545
The second form is the same as the first, since
1548-
<literal>ALL</literal> is the default. The third form invokes the
1549-
aggregate for all distinct values of the expressions found
1550-
in the input rows (ignoring nulls if the function chooses to do so).
1551-
The last form invokes the aggregate once for
1552-
each input row regardless of null or non-null values; since no
1546+
<literal>ALL</literal> is the default.
1547+
The third form invokes the aggregate once for each distinct value
1548+
of the expression (or distinct set of values, for multiple expressions)
1549+
found in the input rows.
1550+
The last form invokes the aggregate once for each input row; since no
15531551
particular input value is specified, it is generally only useful
15541552
for the <function>count(*)</function> aggregate function.
15551553
</para>
15561554

1555+
<para>
1556+
Most aggregate functions ignore null inputs, so that rows in which
1557+
one or more of the expression(s) yield null are discarded. This
1558+
can be assumed to be true, unless otherwise specified, for all
1559+
built-in aggregates.
1560+
</para>
1561+
15571562
<para>
15581563
For example, <literal>count(*)</literal> yields the total number
15591564
of input rows; <literal>count(f1)</literal> yields the number of
1560-
input rows in which <literal>f1</literal> is non-null;
1565+
input rows in which <literal>f1</literal> is non-null, since
1566+
<function>count</> ignores nulls; and
15611567
<literal>count(distinct f1)</literal> yields the number of
15621568
distinct non-null values of <literal>f1</literal>.
15631569
</para>

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy