SQL/MX 2.x Reference Manual (H06.04+)

SQL/MX Functions and Expressions
HP NonStop SQL/MX Reference Manual540440-003
9-81
MAX Function
MAX Function
MAX is an aggregate function that returns the maximum value within a set of values.
The data type of the result is the same as the data type of the argument.
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 on page 6-37.
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)
Examples of MAX
Display the maximum value in the SALARY column:
SELECT MAX (salary)
FROM persnl.employee;
(EXPR)
-----------
175500.00
--- 1 row(s) selected.
MAX ([ALL | DISTINCT] expression)