Edit

Share via


ARRAY_MAX (NoSQL query)

APPLIES TO: NoSQL

Returns the maximal value of elements in the specified array expression.

Syntax

ARRAY_MAX(<array_expr>)  

Arguments

Description
array_expr An array expression.

Return types

Returns a numeric/boolean/string expression.

Examples

The following example shows the results of using this function on arrays with different data types.

SELECT VALUE {
    "case1": ARRAY_MAX([1, 2, 3, 4]),
    "case2": ARRAY_MAX(['abc', 'ABC', 'aBc', 'AbC']),
    "case3": ARRAY_MAX([true, false]),
    "case4": ARRAY_MAX([null, null]),
    "case5": ARRAY_MAX([12, 'abc', true, false, null, undefined])
}
[
    {
        "case1": 4,
        "case2": "abc",
        "case3": true,
        "case4": null,
        "case5": "abc"
    }
]

Remarks

  • The elements in array can be number, string, boolean, or null.
  • Any undefined values are ignored.
  • The following priority order is used (in descending order), when comparing different types of data:
    • string
    • number
    • boolean
    • null
  • This function performs a full scan.