4
*SQL aggregate functions are calculated from values in a column, and return a single value.*
4
SQL group (aggregate) functions operate on sets of values. If you use an aggregate function in a statement containing no GROUP BY clause, it is equivalent to grouping on all rows.
6
6
General syntax for aggregate functions is: ::
8
8
SELECT "function type" ("column_name")
11
The following are examples of aggregate functions:
13
* AVG() - Returns the average value
14
* COUNT() - Returns the number of rows
15
* FIRST() - Returns the first value
16
* LAST() - Returns the last value
17
* MAX() - Returns the largest value
18
* MIN() - Returns the smallest value
19
* SUM() - Returns the sum
11
The following are examples of aggregate functions:
13
**AVG**: Return the average value of the argument. (Does not work with temporal values unless first converted to numeric values.)
16
(DISTINCT): Return the count of a number of different values
18
:doc:`count`: Return a count of the number of rows returned
20
**GROUP_CONCAT**: Return a concatenated string
22
**MAX**: Return the maximum value
24
**MIN**: Return the minimum value
26
**STD**: Return the population standard deviation
28
**STDDEV_POP**: Return the population standard deviation
30
**STDDEV_SAMP**: Return the sample standard deviation
32
**STDDEV**: Return the population standard deviation
34
**SUM**: Return the sum. (Does not work with temporal values unless first converted to numeric values.)
36
**VAR_POP**: Return the population standard variance
38
**VAR_SAMP**: Return the sample variance
40
**VARIANCE**: Return the population standard variance