The GREATEST function of MaxCompute is an aggregate function that compares a group of values and returns the maximum value of the group of values. This topic describes the syntax, parameters, and return value of the GREATEST function.
Syntax
greatest(<var1>, <var2>[,...])
Parameters
var1 and var2: required. Values of the BIGINT, DOUBLE, DECIMAL, DATETIME, or STRING type.
Return value
The maximum value of the input parameters is returned. If implicit conversions are not performed, the return value is of the same data type as the input parameters.
The value null is interpreted as the minimum value.
If the input parameters are of different data types, the input parameters of the DOUBLE, BIGINT, DECIMAL, and STRING types are converted into the DOUBLE type for comparison, and the input parameters of the STRING and DATETIME types are converted into the DATETIME type for comparison. Implicit conversions of other data types are not allowed.
If
odps.sql.hive.compatible
is set to true and an input parameter is set to null, null is returned.
References
For more information, see Other functions.
If the GREATEST function does not meet your requirements, MaxCompute also allows you to use user-defined functions (UDFs). For more information about UDFs, see Overview.
For more information about common errors and FAQ about built-in functions of MaxCompute, see the following topics: