LEAST function in Oracle

LEAST is one of the vital Numeric/Math functions of Oracle. It is used to get the least value from a list of expressions. The LEAST function is supported in the various versions of the Oracle/PLSQL, including, Oracle 12c, Oracle 11g, Oracle 10g, Oracle 9i and Oracle 8i.

Syntax:

LEAST( expr_1, expr_2, ... expr_n )

Parameters:
expr_1, expr_2, … expr_n: It is used to specify the expression to be evaluated.

Example 1:

LEAST( 5, 6, 9, 10 )

Output:

5

Explanation:
The LEAST value is 5 in the above expression.

Example 2:

LEAST( ‘5’, ‘6’, ‘9’, ‘10’ )

Output:

 ‘10’

Explanation:
Since it is a character comparison, hence ‘10’ here is LEAST since it has a lower character set value.

Example 3:

LEAST( ‘ant’, ‘boy’, ‘elephant’, ‘zebra’ )

Output:

 ‘ant’ 

Explanation:
Since it is a character comparison, hence ‘ant’ here is LEAST since it has a lower character set value.

Example 3:

LEAST( ‘ant’, ‘any’, ‘ani’, ‘ana’ )

Output:

 ‘ana’ 

Explanation:
Since it is a character comparison, hence ‘ana’ here is LEAST since it has a lower character set value.