There is a series of functions that can be applied to a set of values (rows) as an argument and supply a result. These functions are referred to as set functions ( set function spec).
<set_function_spec> ::= COUNT (*) | <distinct_function> | <all_function>
COUNT (*), distinct_function, all_function
Set functions operate across groups of values but only return one value. The result comprises one row. If a set function is used in a statement, a similar function must also be applied to each of the other columns in the request. This, however, does not apply to columns that were grouped using GROUP BY. In this case, the value of the set function can be defined for each group.
The argument of a DISTINCT function or an ALL function is a result table or a group (the result table can be grouped using a GROUP condition).
With the exception of the COUNT(*) function, no NULL values are included in the calculation.
No locks are set for certain set functions, irrespective of the isolation level specified when the user connected to the database.
Example table: customer
SELECT SUM(account) sum_account, MIN(account) min_account,
FIXED (AVG(account),7,2) avg_account,
MAX(account) max_account, COUNT(*) number
FROM customer WHERE city = 'Los Angeles'
SUM_ACCOUNT |
MIN_ACCOUNT |
AVG_ACCOUNT |
MAX_ACCOUNT |
NUMBER |
-164.17 |
-4167.79 |
-20.52 |
3770.50 |
8 |