How Can We Help?
Introduction:
In this tutorial, we are going to explain how to use Oracle LEAST function with basic syntax and many examples for better understanding.
LEAST function returns the smallest value of given list of values.
Syntax:
LEAST(value1, value2, ... value_n)
Name | Description |
Value_1 | The first value to evaluate whether it’s smallest value or not. |
Value_2 | The second value to evaluate whether it’s smallest value or not. |
Notes:
- If the first value is not numeric, then every value after the first one is implicitly converted to the data type of the first value before doing the comparison.
- If the first value is of numeric data type, then Oracle determines that the argument with the highest numeric priority, implicitly converts the remaining arguments to that data type before the comparison, and returns that data type.
- If any of the arguments has at least one null the function will return null.
Applies to::
Oracle 19c, Oracle 18c, Oracle 12c, Oracle 11g, Oracle 10g, Oracle 9i, Oracle 8i
Examples:
Let’s take some examples about Oracle LEAST and how to use it:
SELECT LEAST(6, 9, 17, 2)
FROM DUAL;
SELECT LEAST('6', '9', '15', '4')
FROM DUAL;
SELECT LEAST('Catty','Bolly', 'Fansy', 'Look')
FROM DUAL;
SELECT LEAST('windaws', 'windews', 'windows')
FROM DUAL;
SELECT LEAST('Egypt', 'United Stats', null)
FROM DUAL;
SELECT LEAST (5, '9.6', '.00718')
FROM DUAL;
Similar functions to Oracle LEAST:
GREATEST : Add number of months to a date.
In this tutorial, you have learned how to use the LEAST function to get the smallest value of given list of values with many example for better understanding the concept of the function.
Hopefully, it was clear and concise.