Transformation Language Reference > Functions > GREATEST
  

GREATEST

Returns the greatest value from a list of input values. Use this function to return the greatest string, date, or number. By default, the match is case sensitive.

Syntax

GREATEST( value1, [value2, ..., valueN,])
The following table describes the arguments for this command:
Argument
Required/
Optional
Description
value
Required
Any data type except Binary. Data type must be compatible with other values. Value you want to compare against other values. You must enter at least one value argument.
If the value is numeric, and other input values are numeric, all values use the highest precision possible. For example, if some values are Integer data type and others are Double data type, the Data Integration Service converts the values to Double.
CaseFlag
Optional
Must be an integer. Specify a value when the input value argument is a string value. Determines whether the arguments in this function are case sensitive. You can enter any valid transformation expression.
When CaseFlag is a number other than 0, the function is case sensitive.
When CaseFlag is 0, the function is not case sensitive.
Default is case sensitive.

Return Value

value1 if it is the greatest of the input values, value2 if it is the greatest of the input values, and so on.
NULL if any of the arguments is null.

Example

The following expression returns the greatest quantity of items ordered:
GREATEST( QUANTITY1, QUANTITY2, QUANTITY3 )
QUANTITIY1
QUANTITY2
QUANTITY3
RETURN VALUE
150
756
27
756
NULL
5000
97
17
5000
120
1724
965
1724