Returns the minimum value of the input parameters.
Syntax
least(<var1>, <var2>[,...])
Parameters
var: required. The values of the input parameters. The parameters are of the BIGINT, DOUBLE, DECIMAL, DATETIME, or STRING type.
Return value
The minimum value of the input parameters is returned. If implicit conversions are not performed, the return value is of the same data type as the input parameters.
If a data type conversion is performed among the DOUBLE, BIGINT, and STRING types, a value of the DOUBLE type is returned. If a data type conversion is performed between the STRING and DATETIME types, a value of the DATETIME type is returned. If a data type conversion is performed among the DECIMAL, DOUBLE, BIGINT, and STRING types, a value of the DECIMAL type is returned. Implicit conversions of other data types are not allowed.
The value null is interpreted as the minimum value.
If the values of all input parameters are null, null is returned.
Example
-- The return value is 2.
select least(5, 2, 7);
Related functions
For more information, see Other functions.