Oracle/PLSQL: LEAST Function
The Oracle/PLSQL LEAST function returns the smallest value in a list of expressions.
LEAST Function Syntax
The syntax for the LEAST function is:
LEAST( expr1, expr2, ... expr_n )
expr1, expr2, . expr_n are expressions that are evaluated by the LEAST function.
If the datatypes of the expressions are different, all expressions will be converted to whatever datatype expr1 is.
If the comparison is based on a character comparison, one character is considered smaller than another if it has a lower character set value.
Having a NULL value in one of the expressions will return NULL as the least value.
The LEAST function can be used in the following versions of Oracle/PLSQL:
- Oracle 12c, Oracle 11g, Oracle 10g, Oracle 9i, Oracle 8i
LEAST Function Examples
The LEAST function can be used in Oracle/PLSQL. For example:
|LEAST(2, 5, 12, 3)||would return 2|
|LEAST('2', '5', '12', '3')||would return '12'|
|LEAST('apples', 'oranges', 'bananas')||would return 'apples'|
|LEAST('apples', 'applis', 'applas')||would return 'applas'|
|LEAST('apples', 'applis', 'applas', null)||would return NULL|