This Oracle tutorial explains how to use the Oracle/PLSQL LEAST function with syntax and examples.
The Oracle/PLSQL LEAST function returns the smallest value in a list of expressions.
The syntax for the LEAST function in Oracle/PLSQL is:
LEAST( expr1 [, expr2, ... expr_n] )
The first expression to evaluate whether it is the smallest.
Optional. Additional expressions that are to be evaluated.
The LEAST function returns a value that is the same datatype as expr1. 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:
Let's look at some Oracle LEAST function examples and explore how to use the LEAST function in Oracle/PLSQL.
For example:
LEAST(2, 5, 12, 3)
Output: 2
LEAST('2', '5', '12', '3')
Output: '12'
LEAST('apples', 'oranges', 'bananas')
Output: 'apples'
LEAST('apples', 'applis', 'applas')
Output: 'applas'
LEAST('apples', 'applis', 'applas', null)
Output: NULL