tech on the net

Oracle/PLSQL: Least Function

In Oracle/PLSQL, the least function returns the smallest value in a list of expressions.

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.

Note

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.

Applies To

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