Update aggregate-function docs for STDDEV, VARIANCE.

This commit is contained in:
Tom Lane 2000-07-17 03:52:28 +00:00
parent bec98a31c5
commit d06ebdb8d3
1 changed files with 60 additions and 18 deletions

View File

@ -1539,7 +1539,7 @@ Not defined by this name. Implements the intersection operator '#'
<para> <para>
<firstterm>Aggregate functions</firstterm> allow the generation of simple <firstterm>Aggregate functions</firstterm> allow the generation of simple
statistics about the values of particular columns over the selected set statistics about the values of given expressions over the selected set
of rows. of rows.
<!-- <!--
See also <xref linkend="sql" endterm="aggregates-tutorial"> and See also <xref linkend="sql" endterm="aggregates-tutorial"> and
@ -1556,6 +1556,7 @@ Not defined by this name. Implements the intersection operator '#'
<title>Aggregate Functions</title> <title>Aggregate Functions</title>
<tgroup cols="4"> <tgroup cols="4">
<thead> <thead>
<row> <row>
<entry>Function</entry> <entry>Function</entry>
<entry>Returns</entry> <entry>Returns</entry>
@ -1563,6 +1564,7 @@ Not defined by this name. Implements the intersection operator '#'
<entry>Example</entry> <entry>Example</entry>
<entry>Notes</entry> <entry>Notes</entry>
</row> </row>
</thead> </thead>
<tbody> <tbody>
<row> <row>
@ -1572,45 +1574,85 @@ Not defined by this name. Implements the intersection operator '#'
<entry>COUNT(*)</entry> <entry>COUNT(*)</entry>
<entry></entry> <entry></entry>
</row> </row>
<row> <row>
<entry>COUNT(<replaceable class="parameter">column-name</replaceable>)</entry> <entry>COUNT(<replaceable class="parameter">expression</replaceable>)</entry>
<entry>int4</entry> <entry>int4</entry>
<entry>Counts the selected rows for which the value of <replaceable class="parameter">column-name</replaceable> is not NULL.</entry> <entry>Counts the selected rows for which the value of
<replaceable class="parameter">expression</replaceable> is not
NULL.</entry>
<entry>COUNT(age)</entry> <entry>COUNT(age)</entry>
<entry></entry> <entry></entry>
</row> </row>
<row> <row>
<entry>SUM(<replaceable class="parameter">column-name</replaceable>)</entry> <entry>SUM(<replaceable class="parameter">expression</replaceable>)</entry>
<entry>Same as the data type of the column being summed.</entry> <entry>Depends on the data type being summed.</entry>
<entry>Finds the total obtained by adding the values of <replaceable class="parameter">column-name</replaceable> across all selected rows.</entry> <entry>Finds the total obtained by adding the values of <replaceable class="parameter">expression</replaceable> across all selected rows.</entry>
<entry>SUM(hours)</entry> <entry>SUM(hours)</entry>
<entry>Summation is supported on the following data types: int8, int4, int2, float4, float8, money, interval, numeric</entry> <entry>Summation is supported on the following data types: int8, int4,
int2, float4, float8, money, interval, numeric. The result is numeric
for any integer type, float8 for either float4 or float8 input,
otherwise the same as the input data type.</entry>
</row> </row>
<row> <row>
<entry>MAX(<replaceable class="parameter">column-name</replaceable>)</entry> <entry>MAX(<replaceable class="parameter">expression</replaceable>)</entry>
<entry>Same as the data type of the column whose maximum value is sought.</entry> <entry>Same as the data type of the input expression.</entry>
<entry>The maximum value of <replaceable class="parameter">column-name</replaceable> across all selected rows.</entry> <entry>The maximum value of <replaceable class="parameter">expression</replaceable> across all selected rows.</entry>
<entry>MAX(age)</entry> <entry>MAX(age)</entry>
<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> <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>
</row> </row>
<row> <row>
<entry>MIN(<replaceable class="parameter">column-name</replaceable>)</entry> <entry>MIN(<replaceable class="parameter">expression</replaceable>)</entry>
<entry>same as the data type of the column whose minimum value is sought.</entry> <entry>Same as the data type of the input expression.</entry>
<entry>The minimum value of <replaceable class="parameter">column-name</replaceable> across all selected rows.</entry> <entry>The minimum value of <replaceable class="parameter">expression</replaceable> across all selected rows.</entry>
<entry>MIN(age)</entry> <entry>MIN(age)</entry>
<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> <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>
</row> </row>
<row> <row>
<entry>AVG(<replaceable class="parameter">column-name</replaceable>)</entry> <entry>AVG(<replaceable class="parameter">expression</replaceable>)</entry>
<entry>Same as the data type of the column being averaged.</entry> <entry>Depends on the data type being averaged.</entry>
<entry>The average (mean) of the values in the given column across all selected rows.</entry> <entry>The average (mean) of the given values across all selected rows.</entry>
<entry>AVG(age)</entry> <entry>AVG(age+1)</entry>
<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> <entry>Finding the mean value is supported on the following data
types: int8, int4, int2, float4, float8, interval, numeric. The
result is numeric for any integer type, float8 for either float4 or
float8 input, otherwise the same as the input data type.</entry>
</row> </row>
<row>
<entry>VARIANCE(<replaceable class="parameter">expression</replaceable>)</entry>
<entry>Depends on the input data type.</entry>
<entry>The sample variance of the given values.</entry>
<entry>VARIANCE(reading)</entry>
<entry>Finding the variance is supported on the following data
types: int8, int4, int2, float4, float8, numeric. The result is
float8 for float4 or float8 input, otherwise numeric.</entry>
</row>
<row>
<entry>STDDEV(<replaceable class="parameter">expression</replaceable>)</entry>
<entry>Depends on the input data type.</entry>
<entry>The sample standard deviation of the given values.</entry>
<entry>STDDEV(reading)</entry>
<entry>Finding the standard deviation is supported on the following
data types: int8, int4, int2, float4, float8, numeric. The result is
float8 for float4 or float8 input, otherwise numeric.</entry>
</row>
</tbody> </tbody>
</tgroup> </tgroup>
</table> </table>
</para> </para>
<para>
It should be noted that except for COUNT, these functions return NULL
when no rows are selected. In particular, SUM of no rows returns NULL,
not zero as one might expect.
</para>
</sect1> </sect1>
</chapter> </chapter>