Neoview SQL Reference Manual (R2.4)
MAX/MAXIMUM Function
MAX is an aggregate function that returns the maximum value within a set of values. MAXIMUM
is the equivalent of MAX wherever the function name MAX appears within a statement. The
data type of the result is the same as the data type of the argument.
MAX | MAXIMUM ([ALL | DISTINCT] expression)
ALL | DISTINCT
specifies whether duplicate values are included in the computation of the maximum of the
expression. The default option is ALL, which causes duplicate values to be included. If
you specify DISTINCT, duplicate values are eliminated before the MAX function is applied.
expression
specifies an expression that determines the values to include in the computation of the
maximum. The expression cannot contain an aggregate function or a subquery. The
DISTINCT clause specifies that the MAX function operates on distinct values from the
one-column table derived from the evaluation of expression. All nulls are eliminated
before the function is applied to the set of values. If the result table is empty, MAX returns
NULL.
See “Expressions” (page 240).
Considerations for MAX
Operands of the Expression
The expression includes columns from the rows of the SELECT result table but cannot include
an aggregate function. These expressions are valid:
MAX (SALARY)
MAX (SALARY * 1.1)
MAX (PARTCOST * QTY_ORDERED)
Example of MAX
Display the maximum value in the SALARY column:
SELECT MAX (salary)
FROM persnl.employee;
(EXPR)
-----------
175500.00
--- 1 row(s) selected.
402 SQL Functions and Expressions