MIN scalar function

The MIN function returns the minimum value in a set of values.

Read syntax diagramSkip visual syntax diagramMIN(expression ,expression )

The schema is SYSIBM.

expression
An expression that returns a value of any built-in data type or user-defined data type that is comparable with data type of the other arguments. The data type cannot be a LOB, distinct type base on a LOB, XML, array, cursor, row, or structured type.

The result of the function is the smallest argument value. The result can be null if at least one argument can be null; the result is the null value if any argument is null.

The selected argument is converted, if necessary, to the attributes of the result. The attributes of the result are determined by the data types of all the arguments as explained in Rules for result data types.

Notes

  • The MIN scalar function is a synonym for the LEAST scalar function.
  • The MIN function cannot be used as a source function when creating a user-defined function. Because this function accepts any comparable data types as arguments, it is not necessary to create additional signatures to support user-defined data types.

Example

Return the bonus for an employee, the LESSER of 5000 and 5% of the employee's salary.
   SELECT EMPNO, MIN(SALARY * 0.05, 5000)
     FROM EMPLOYEE