MAX and MIN operate on columns that contain character, graphic, numeric, or date/time values.
Here is an example of a column function:
MAX(expression) or MIN(expression)
The parentheses
are required. expression is most often a column name, but can be:
A column name in a function must not refer to a long string column or a column derived from a column function. (A column of a view can be derived from a function.) Column functions cannot be nested within other column functions.
The data type of the result of the MAX or MIN function always allows nulls even if the operand of these functions is NOT NULL. Null values are not included in the calculation made by a built-in function.
The following example includes more than one column function in the SELECT statement. For department 10, it calculates and displays the sum of employee salaries, the minimum, average, and maximum salary, and the number of employees (COUNT) in the department.
SELECT SUM(SALARY), MIN(SALARY), AVG(SALARY), MAX(SALARY), COUNT(*) FROM Q.STAFF WHERE DEPT = 10
If you use MAX or MIN with character data, remember that a binary collating sequence is applied when comparing data.
[ Previous Page | Next Page | Contents | Index ]