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

max

Function

The max function is used to return the maximum value.

Syntax

max(col)

Parameters

Parameter

Mandatory

Description

col

Yes

Column values can be of any type except BOOLEAN.

Return Values

Returns a value of type DOUBLE.

The return value type is the same as the col type. Return rules are as follows:

  • If col is NULL, that row is excluded from the calculation.
  • If col is of type BOOLEAN, it is not allowed in the computation.

Examples

  • Calculate the maximum inventory (items) across all items. Example command:
    select max(items) from warehouse;

    Result:

    _c0         
    900        
  • Used with GROUP BY to find the maximum inventory for each warehouse. Example command:
    select warehouseId, max(items) from warehouse group by warehouseId;

    Result:

    warehouseId _c1         
    city1    200         
    city2    300         
    city3    400