MAX and MIN: Finding the Maximum or Minimum Value

How to:

Available Languages: reporting, Maintain

The MAX and MIN functions return the maximum or minimum value, respectively, from a list of values.


Top of page

x
Syntax: How to Find the Maximum or Minimum Value
{MAX|MIN}(value1, value2, ...)

where:

MAX

Returns the maximum value.

MIN

Returns the minimum value.

value1, value2

Numeric

Are the values for which the maximum or minimum value is returned, the name of a field that contains the values, or an expression that returns the values. If you supply an expression, use parentheses as needed to ensure the correct order of evaluation.



Example: Determining the Minimum Value

MIN returns either the value of the ED_HRS field or the constant 30, whichever is lower:

TABLE FILE EMPLOYEE
PRINT ED_HRS AND COMPUTE
MIN_EDHRS_30/D12.2 = MIN(ED_HRS, 30);BY LAST_NAME BY FIRST_NAME
WHERE DEPARTMENT EQ 'MIS';
END

The output is:

LAST_NAME         FIRST_NAME  ED_HRS     MIN_EDHRS_30 
---------         ---------- ------      ------------ 
BLACKWOOD         ROSEMARIE   75.00             30.00 
CROSS             BARBARA     45.00             30.00 
GREENSPAN         MARY        25.00             25.00 
JONES             DIANE       50.00             30.00 
MCCOY             JOHN          .00               .00 
SMITH             MARY        36.00             30.00

WebFOCUS