ODBC Server Reference Manual
CORE SQL Language
HP NonStop ODBC Server Reference Manual—429151-002
3-27
Aggregates
Aggregates
The NonStop ODBC Server supports all of the CORE SQL aggregate functions (AVG,
COUNT, MAX, MIN, and SUM).
AVG
The AVG aggregate function has the following syntax:
The AVG function returns the average of the values in the column, in the same data
type as the argument you supply.
If you specify DISTINCT, the AVG function calculates the result after excluding
duplicate and null values of the argument. If you do not specify DISTINCT, duplicate
values are retained; expression must contain at least one column-name and must
not contain any aggregate functions.
COUNT
The COUNT aggregate function has the following syntax:
The COUNT function returns the total number of values in the column, in numeric data
type.
If only column-name is specified, the column data type must be a numeric data type
such as NUMERIC and not a nonnumeric type such as CHAR.
If you specify DISTINCT, the COUNT function calculates the result after excluding
duplicate values of the argument. COUNT (*) counts all values, including duplicate and
null values.
(NonStop SQL/MP does not support the COUNT function when only column-name is
specified in a query; however, NonStop ODBC has implemented the COUNT function
for ODBC clients that need this function.)
MAX
The MAX aggregate function has the following syntax:
AVG ( { DISTINCT column-name } )
{ expression }
COUNT ( { DISTINCT column-name } )
{ column-name }
{ * }
MAX ( { DISTINCT column-name } )
{ expression }