Clarify documentation of handling of null arguments for aggregates.
Per discussion.
This commit is contained in:
parent
4ff6856cb1
commit
21076076e9
|
@ -1,4 +1,4 @@
|
||||||
<!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.530 2010/08/24 06:30:43 itagaki Exp $ -->
|
<!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.531 2010/09/01 18:22:29 tgl Exp $ -->
|
||||||
|
|
||||||
<chapter id="functions">
|
<chapter id="functions">
|
||||||
<title>Functions and Operators</title>
|
<title>Functions and Operators</title>
|
||||||
|
@ -10034,7 +10034,7 @@ SELECT NULLIF(value, '(none)') ...
|
||||||
<entry>
|
<entry>
|
||||||
array of the argument type
|
array of the argument type
|
||||||
</entry>
|
</entry>
|
||||||
<entry>input values concatenated into an array</entry>
|
<entry>input values, including nulls, concatenated into an array</entry>
|
||||||
</row>
|
</row>
|
||||||
|
|
||||||
<row>
|
<row>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<!-- $PostgreSQL: pgsql/doc/src/sgml/syntax.sgml,v 1.153 2010/08/13 01:12:38 rhaas Exp $ -->
|
<!-- $PostgreSQL: pgsql/doc/src/sgml/syntax.sgml,v 1.154 2010/09/01 18:22:29 tgl Exp $ -->
|
||||||
|
|
||||||
<chapter id="sql-syntax">
|
<chapter id="sql-syntax">
|
||||||
<title>SQL Syntax</title>
|
<title>SQL Syntax</title>
|
||||||
|
@ -1541,23 +1541,29 @@ sqrt(2)
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
The first form of aggregate expression invokes the aggregate
|
The first form of aggregate expression invokes the aggregate
|
||||||
across all input rows for which the given expression(s) yield
|
once for each input row.
|
||||||
non-null values. (Actually, it is up to the aggregate function
|
|
||||||
whether to ignore null values or not — but all the standard ones do.)
|
|
||||||
The second form is the same as the first, since
|
The second form is the same as the first, since
|
||||||
<literal>ALL</literal> is the default. The third form invokes the
|
<literal>ALL</literal> is the default.
|
||||||
aggregate for all distinct values of the expressions found
|
The third form invokes the aggregate once for each distinct value
|
||||||
in the input rows (ignoring nulls if the function chooses to do so).
|
of the expression (or distinct set of values, for multiple expressions)
|
||||||
The last form invokes the aggregate once for
|
found in the input rows.
|
||||||
each input row regardless of null or non-null values; since no
|
The last form invokes the aggregate once for each input row; since no
|
||||||
particular input value is specified, it is generally only useful
|
particular input value is specified, it is generally only useful
|
||||||
for the <function>count(*)</function> aggregate function.
|
for the <function>count(*)</function> aggregate function.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
Most aggregate functions ignore null inputs, so that rows in which
|
||||||
|
one or more of the expression(s) yield null are discarded. This
|
||||||
|
can be assumed to be true, unless otherwise specified, for all
|
||||||
|
built-in aggregates.
|
||||||
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
For example, <literal>count(*)</literal> yields the total number
|
For example, <literal>count(*)</literal> yields the total number
|
||||||
of input rows; <literal>count(f1)</literal> yields the number of
|
of input rows; <literal>count(f1)</literal> yields the number of
|
||||||
input rows in which <literal>f1</literal> is non-null;
|
input rows in which <literal>f1</literal> is non-null, since
|
||||||
|
<function>count</> ignores nulls; and
|
||||||
<literal>count(distinct f1)</literal> yields the number of
|
<literal>count(distinct f1)</literal> yields the number of
|
||||||
distinct non-null values of <literal>f1</literal>.
|
distinct non-null values of <literal>f1</literal>.
|
||||||
</para>
|
</para>
|
||||||
|
|
Loading…
Reference in a new issue