MAX

All functions > AGGREGATE > MAX

Returns the maximum value in the group.

Syntax

MAX(expr: T) → T
sql

Type Parameters:

  • T: Any comparable type (numeric, string, date, timestamp, boolean)

Arguments

ParameterTypeRequiredDescription
exprTYesThe expression to find the maximum value of
num_valuesANYNoOptional number of maximum values to return as array

Returns

The maximum value, or array of top N values if num_values specified

Notes

  • Returns the largest value in the group
  • Works with numeric, string, and date types
  • NULL values are excluded from the calculation
  • Returns NULL if all values are NULL or group is empty
  • With num_values parameter, returns an array of the N largest values
  • Can be used with WHERE clause to filter before aggregation
  • Can be used with GROUP BY clause for grouped aggregation
Last update at: 2025/10/13 10:23:46