What is the usage of the greatest function in Oracle?
In Oracle database, the GREATEST function is used to return the largest value from the given parameters. It accepts two or more parameters and returns the maximum value among them.
Grammar rules
GREATEST(value1, value2, ...)
Parameters:
- value1, value2, etc: the values to be compared. They can be any expression, including column names, constants, or expressions.
Return value:
- The return value is the maximum value in the parameters.
The employees were given a bonus for their hard work.
– The workers received a reward for their dedication.
SELECT GREATEST(10, 20, 30) as max_value FROM dual;
Output:
MAX_VALUE
---------
30
In the example provided above, the GREATEST function returns the maximum value from the given parameters (10, 20, and 30), which is 30.