Purpose
The LEAST function returns the smallest value from a list of one or more expressions.
Syntax
LEAST(expr [, expr ]...)
Parameters
The expr parameter is a list of one or more expressions. The data type can be NUMBER, FLOAT, BINARY_FLOAT, BINARY_DOUBLE, CHAR, VARCHAR2, NCHAR, NVARCHAR2, or CLOB.
Return type
The database uses the first expr parameter to determine the return type. If the data types of the remaining parameters differ from the data type of the first expr parameter, the database implicitly converts each subsequent expr parameter to the data type of the first expr parameter.
If the data type of the first
exprparameter isNUMBER,FLOAT,BINARY_FLOAT, orBINARY_DOUBLE, the return type is the same as the data type of the firstexprparameter.If the data type of the first
exprparameter isCHAR,VARCHAR2, orCLOB, the return type isVARCHAR2.If the data type of the first
exprparameter isNCHARorNVARCHAR2, the return type isNVARCHAR2.
Examples
Compare the strings
AC,BB, andCand return the smallest string.obclient> SELECT LEAST('AC','BB','C') "MIN" FROM DUAL; +-----+ | MIN | +-----+ | AC | +-----+ 1 row in setCompare the integers
1, the string6, and5.555and return the smallest value.obclient> SELECT LEAST (1,'6','5.555') "MIN" FROM DUAL; +-----+ | MIN | +-----+ | 1 | +-----+ 1 row in set
