Oracle Conversion Function - Oracle/PLSQL LEAST Function






This Oracle tutorial explains how to use the Oracle/PLSQL LEAST function.

The least function returns the smallest value in a list. The syntax for the least function is:

least( expr1, expr2, ... expr_n )

If the data types of the expressions are different, all expressions are converted to expr1's data type. If a NULL value is in the list, least function returns NULL.

Syntax

The syntax for the Oracle/PLSQL LEAST function is:

LEAST( expr1, expr2, ... expr_n )

expr1, expr2, . expr_n are expressions that are evaluated by the LEAST function.

If the data types of the expressions are different, all expressions will be converted to what datatype expr1 is.

Having a NULL value in one of the expressions will return NULL as the least value.





Example


SQL> select least(1, 2, 3, 4) from dual;
-- w  ww .  j  a va2  s.c o  m
LEAST(1,2,3,4)
--------------
             1

SQL> select least('1', '2', 'a', 'b') from dual;

L
-
1

SQL> select least('a', 'b', 'c') from dual;

L
-
a

SQL> select least('a', 'b', 'c', null) from dual;

L
-