ALLBASE/SQL Reference Manual (36216-90216)

236 Chapter8
Expressions
Aggregate Functions
Aggregate Functions
Aggregate functions specify a value computed using data described in an argument. The
argument, enclosed in parentheses, is an expression. The value of the expression is
computed using each row that satisfies a SELECT statement. Aggregate functions can be
specified in the select list and the HAVING clause. Refer to the explanation of the SELECT
statement for more details.
Scope
SQL SELECT Statements
SQL Syntax
{ AVG ({
Expression
[ALL
DISTINCT]
ColumnName
} )
MAX ({
Expression
[ALL
DISTINCT]
ColumnName
} )
MIN ({
Expression
[ALL
DISTINCT]
ColumnName
} )
SUM ({
Expression
[ALL
DISTINCT]
ColumnName
} )
COUNT ({
*
[ALL
DISTINCT]
ColumnName
} ) }
Parameters
Expression
specifies a value to be obtained.
AVG computes the arithmetic mean of the values in the argument; NULL
values are ignored. AVG can be applied only to numeric data types and to
the INTERVAL type. When applied to FLOAT or REAL, the result is
FLOAT. When applied to INTEGER or SMALLINT, the result is
INTEGER, and fractions are discarded. When applied to DECIMAL, the
result is DECIMAL. When applied to INTERVAL, the result is
INTERVAL.
MAX finds the largest of the values in the argument; NULL values are ignored.
MAX can be applied to numeric, alphanumeric, BINARY (not LONG), and
date/time data types; the result is the same data type as that of the
argument.
MIN finds the smallest of the values in the argument; NULL values are
ignored. MIN can be applied to numeric, alphanumeric, BINARY (not
LONG), and date/time data types; the result is the same data type as that
of the argument.