greatest
This section contains reference documentation for the greatest function.
Last updated
Was this helpful?
This section contains reference documentation for the greatest function.
Returns the larger of two values. This is a polymorphic function that preserves the input numeric type.
greatest(col1, col2)
col1
INT, LONG, FLOAT, DOUBLE, BIG_DECIMAL
First value
col2
INT, LONG, FLOAT, DOUBLE, BIG_DECIMAL
Second value
Returns the same numeric type as the inputs (or the wider type if inputs differ).
SELECT greatest(10, 5) AS value
FROM myTable10
SELECT greatest(10.5, 10.3) AS value
FROM myTable10.5
SELECT greatest(100, 50L) AS mixed_int_long, greatest(3.14F, 2.71F) AS float_greatest, greatest(3.14, 2.71) AS double_greatest
FROM myTableReturns INT/LONG, FLOAT, DOUBLE respectively (preserving input type or the wider type).
Last updated
Was this helpful?
Was this helpful?

