Returns the smallest value from a list of expressions. LEAST supports all data types, including VARIANT.
LEAST(( <expr1> [ , <expr2> ... ] )
Copy
Arguments¶exprN
The arguments must include at least one expression. All the expressions should be of the same type or compatible types.
The first argument determines the return type:
If the first type is numeric, then the return type is ‘widened’ according to the numeric types in the list of all arguments.
If the first type is not numeric, then all other arguments must be convertible to the first type.
If any argument is NULL, returns NULL.
Collation details¶The collation specifications of all input arguments must be compatible.
The comparisons follow the collation based on the input arguments’ collations and precedences.
The collation of the result of the function is the highest-precedence collation of the inputs.
The following examples use the LEAST function:
SELECT LEAST(1, 3, 0, 4);
Copy
+-------------------+ | LEAST(1, 3, 0, 4) | |-------------------| | 0 | +-------------------+
SELECT col_1, col_2, col_3, LEAST(col_1, col_2, col_3) AS least FROM (SELECT 1 AS col_1, 2 AS col_2, 3 AS col_3 UNION ALL SELECT 2, 4, -1 UNION ALL SELECT 3, 6, NULL);
Copy
+-------+-------+-------+-------+ | COL_1 | COL_2 | COL_3 | LEAST | |-------+-------+-------+-------| | 1 | 2 | 3 | 1 | | 2 | 4 | -1 | -1 | | 3 | 6 | NULL | NULL | +-------+-------+-------+-------+
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4