top of page
CerebroSQL

MySQL: 

LEAST

Syntax:
LEAST(value1,value2,...)

With two or more arguments, returns the smallest (minimum-valued)
argument. The arguments are compared using the following rules:

o If any argument is NULL, the result is NULL. No comparison is needed.

o If all arguments are integer-valued, they are compared as integers.

o If at least one argument is double precision, they are compared as
double-precision values. Otherwise, if at least one argument is a
DECIMAL value, they are compared as DECIMAL values.

o If the arguments comprise a mix of numbers and strings, they are
compared as strings.

o If any argument is a nonbinary (character) string, the arguments are
compared as nonbinary strings.

o In all other cases, the arguments are compared as binary strings.

The return type of LEAST() is the aggregated type of the comparison
argument types.

Example

mysql> SELECT LEAST(2,0);
-> 0
mysql> SELECT LEAST(34.0,3.0,5.0,767.0);
-> 3.0
mysql> SELECT LEAST('B','A','C');
-> 'A'

bottom of page