Updated on 2026-11-06 GMT+08:00

greatest

The greatest function is used to return the maximum value from a list.

Syntax

greatest(T v1, T v2, ...)

Parameters

Parameter

Mandatory

Type

Description

v1

Yes

DOUBLE, BIGINT, or DECIMAL

The format of parameter v1 includes floating-point format, integer format, and DECIMAL format.

v2

Yes

DOUBLE, BIGINT, or DECIMAL

The format of parameter v2 includes floating-point format, integer format, and DECIMAL format.

Return Values

Returns a value of type DOUBLE.

If any parameter is NULL, the NULL is ignored and the maximum value is returned.

Example Code

Returns 4.0.

select greatest(1,2.0,3,4.0); 

Returns 4.

select greatest(null,4);