MIN
The MIN scalar function returns the minimum value in a set of values.
The arguments must be compatible. Character-string arguments are compatible with datetime values. The arguments cannot be DataLink or XML values.
- expression
- An expression that returns a value of any built-in numeric or string data type. If one of the arguments is numeric, then character and graphic string arguments are cast to numeric before evaluating the function.
The result of the function is the minimum argument value. The result can be null if at least one argument can be null; the result is the null value if one of the arguments is null.
The selected argument is converted, if necessary, to the attributes of the result. The attributes of the result are determined by all the operands as explained in Rules for result data types.
If a collating sequence other than *HEX is in effect when the statement is executed and the arguments are SBCS data, mixed data, or Unicode data, the weighted values of the strings are compared instead of the actual values. The weighted values are based on the collating sequence.
Note
Syntax alternatives: LEAST can be specified as a synonym for MIN.
Examples
- Assume the host variable M1 is a DECIMAL(2,1) host variable with
a value of 5.5, host variable M2 is a DECIMAL(3,1) host variable with
a value of 4.5, and host variable M3 is a DECIMAL(3,2) host variable
with a value of 6.25.
Returns the value 4.50.SELECT MIN(:M1,:M2,:M3) FROM SYSIBM.SYSDUMMY1
- Assume the host variable M1 is a CHARACTER(2) host variable with
a value of 'AA', host variable M2 is a CHARACTER(3) host variable
with a value of 'AAA', and host variable M3 is a CHARACTER(4) host
variable with a value of 'AAAA'.
Returns the value 'AA '.SELECT MIN(:M1,:M2,:M3) FROM SYSIBM.SYSDUMMY1