All Products
Search
Document Center

MaxCompute:GREATEST

Last Updated:Feb 21, 2024

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