Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit d06ebdb

Browse files
committed
Update aggregate-function docs for STDDEV, VARIANCE.
1 parent bec98a3 commit d06ebdb

File tree

1 file changed

+60
-18
lines changed

1 file changed

+60
-18
lines changed

doc/src/sgml/func.sgml

+60-18
Original file line numberDiff line numberDiff line change
@@ -1539,7 +1539,7 @@ Not defined by this name. Implements the intersection operator '#'
15391539

15401540
<para>
15411541
<firstterm>Aggregate functions</firstterm> allow the generation of simple
1542-
statistics about the values of particular columns over the selected set
1542+
statistics about the values of given expressions over the selected set
15431543
of rows.
15441544
<!--
15451545
See also <xref linkend="sql" endterm="aggregates-tutorial"> and
@@ -1556,13 +1556,15 @@ Not defined by this name. Implements the intersection operator '#'
15561556
<title>Aggregate Functions</title>
15571557
<tgroup cols="4">
15581558
<thead>
1559+
15591560
<row>
15601561
<entry>Function</entry>
15611562
<entry>Returns</entry>
15621563
<entry>Description</entry>
15631564
<entry>Example</entry>
15641565
<entry>Notes</entry>
15651566
</row>
1567+
15661568
</thead>
15671569
<tbody>
15681570
<row>
@@ -1572,45 +1574,85 @@ Not defined by this name. Implements the intersection operator '#'
15721574
<entry>COUNT(*)</entry>
15731575
<entry></entry>
15741576
</row>
1577+
15751578
<row>
1576-
<entry>COUNT(<replaceable class="parameter">column-name</replaceable>)</entry>
1579+
<entry>COUNT(<replaceable class="parameter">expression</replaceable>)</entry>
15771580
<entry>int4</entry>
1578-
<entry>Counts the selected rows for which the value of <replaceable class="parameter">column-name</replaceable> is not NULL.</entry>
1581+
<entry>Counts the selected rows for which the value of
1582+
<replaceable class="parameter">expression</replaceable> is not
1583+
NULL.</entry>
15791584
<entry>COUNT(age)</entry>
15801585
<entry></entry>
15811586
</row>
1587+
15821588
<row>
1583-
<entry>SUM(<replaceable class="parameter">column-name</replaceable>)</entry>
1584-
<entry>Same as the data type of the column being summed.</entry>
1585-
<entry>Finds the total obtained by adding the values of <replaceable class="parameter">column-name</replaceable> across all selected rows.</entry>
1589+
<entry>SUM(<replaceable class="parameter">expression</replaceable>)</entry>
1590+
<entry>Depends on the data type being summed.</entry>
1591+
<entry>Finds the total obtained by adding the values of <replaceable class="parameter">expression</replaceable> across all selected rows.</entry>
15861592
<entry>SUM(hours)</entry>
1587-
<entry>Summation is supported on the following data types: int8, int4, int2, float4, float8, money, interval, numeric</entry>
1593+
<entry>Summation is supported on the following data types: int8, int4,
1594+
int2, float4, float8, money, interval, numeric. The result is numeric
1595+
for any integer type, float8 for either float4 or float8 input,
1596+
otherwise the same as the input data type.</entry>
15881597
</row>
1598+
15891599
<row>
1590-
<entry>MAX(<replaceable class="parameter">column-name</replaceable>)</entry>
1591-
<entry>Same as the data type of the column whose maximum value is sought.</entry>
1592-
<entry>The maximum value of <replaceable class="parameter">column-name</replaceable> across all selected rows.</entry>
1600+
<entry>MAX(<replaceable class="parameter">expression</replaceable>)</entry>
1601+
<entry>Same as the data type of the input expression.</entry>
1602+
<entry>The maximum value of <replaceable class="parameter">expression</replaceable> across all selected rows.</entry>
15931603
<entry>MAX(age)</entry>
15941604
<entry>Finding the maximum value is supported on the following data types: int8, int4, int2, float4, float8, date, time, timetz, money, timestamp, interval, text, numeric.</entry>
15951605
</row>
1606+
15961607
<row>
1597-
<entry>MIN(<replaceable class="parameter">column-name</replaceable>)</entry>
1598-
<entry>same as the data type of the column whose minimum value is sought.</entry>
1599-
<entry>The minimum value of <replaceable class="parameter">column-name</replaceable> across all selected rows.</entry>
1608+
<entry>MIN(<replaceable class="parameter">expression</replaceable>)</entry>
1609+
<entry>Same as the data type of the input expression.</entry>
1610+
<entry>The minimum value of <replaceable class="parameter">expression</replaceable> across all selected rows.</entry>
16001611
<entry>MIN(age)</entry>
16011612
<entry>Finding the minimum value is supported on the following data types: int8, int4, int2, float4, float8, date, time, timetz, money, timestamp, interval, text, numeric.</entry>
16021613
</row>
1614+
16031615
<row>
1604-
<entry>AVG(<replaceable class="parameter">column-name</replaceable>)</entry>
1605-
<entry>Same as the data type of the column being averaged.</entry>
1606-
<entry>The average (mean) of the values in the given column across all selected rows.</entry>
1607-
<entry>AVG(age)</entry>
1608-
<entry>Finding the mean value is supported on the following data types: int8, int4, int2, float4, float8, money, interval, numeric. Note that as the return type is the same as that of the data being averaged, using AVG() on discrete data will give a rounded result.</entry>
1616+
<entry>AVG(<replaceable class="parameter">expression</replaceable>)</entry>
1617+
<entry>Depends on the data type being averaged.</entry>
1618+
<entry>The average (mean) of the given values across all selected rows.</entry>
1619+
<entry>AVG(age+1)</entry>
1620+
<entry>Finding the mean value is supported on the following data
1621+
types: int8, int4, int2, float4, float8, interval, numeric. The
1622+
result is numeric for any integer type, float8 for either float4 or
1623+
float8 input, otherwise the same as the input data type.</entry>
16091624
</row>
1625+
1626+
<row>
1627+
<entry>VARIANCE(<replaceable class="parameter">expression</replaceable>)</entry>
1628+
<entry>Depends on the input data type.</entry>
1629+
<entry>The sample variance of the given values.</entry>
1630+
<entry>VARIANCE(reading)</entry>
1631+
<entry>Finding the variance is supported on the following data
1632+
types: int8, int4, int2, float4, float8, numeric. The result is
1633+
float8 for float4 or float8 input, otherwise numeric.</entry>
1634+
</row>
1635+
1636+
<row>
1637+
<entry>STDDEV(<replaceable class="parameter">expression</replaceable>)</entry>
1638+
<entry>Depends on the input data type.</entry>
1639+
<entry>The sample standard deviation of the given values.</entry>
1640+
<entry>STDDEV(reading)</entry>
1641+
<entry>Finding the standard deviation is supported on the following
1642+
data types: int8, int4, int2, float4, float8, numeric. The result is
1643+
float8 for float4 or float8 input, otherwise numeric.</entry>
1644+
</row>
1645+
16101646
</tbody>
16111647
</tgroup>
16121648
</table>
16131649
</para>
1650+
1651+
<para>
1652+
It should be noted that except for COUNT, these functions return NULL
1653+
when no rows are selected. In particular, SUM of no rows returns NULL,
1654+
not zero as one might expect.
1655+
</para>
16141656
</sect1>
16151657
</chapter>
16161658

0 commit comments

Comments
 (0)