LEAST
Syntax
LEAST
(
expr1 IN anynonarray,
expr_array IN variadic anyarray
)
RETURNS anynonarray;
Overview
The LEAST function returns the smallest value among the passed in arguments. If any of the arguments are NULL, the entire result will be NULL.
The PostgreSQL default function returns NULL if and only if all arguments are NULL, which is NULL if even one is NULL.
Parameters
Parameter
Description
expr1
anynonarray
type: the first value to compare. Must be non-NULL.
expr_array
VARIADIC anyarray
type: an array containing additional arguments. If there is a NULL in the array, the entire result is NULL.
The elements of the array must have the same type as expr1.
Example
# test 1
SELECT oracle.LEAST(5, 3, 9);
least
-------
3
(1 row)
# test 2
SELECT oracle.LEAST('apple'::text, 'banana', 'cherry'); -- result: apple (Compare strings alphabetically)
least
-------
apple
(1 row)
# test 3
SELECT oracle.LEAST(10, NULL, 7); -- result: NULL
least
-------
(1 row)
Last updated