MAX (Azure Cosmos DB)

APPLIES TO: NoSQL

This aggregate function returns the maximum of the values in the expression.

Syntax

MAX(<scalar_expr>)  

Arguments

scalar_expr
Is a scalar expression.

Return types

Returns a scalar expression.

Examples

The following example returns the maximum value of propertyA:

SELECT MAX(c.propertyA)
FROM c

Remarks

This system function will benefit from a range index. The arguments in MAX can be number, string, boolean, or null. Any undefined values will be ignored.

When comparing different types data, the following priority order is used (in descending order):

  • string
  • number
  • boolean
  • null

Next steps