Max
Max( value_1, value_2, ... )
Max( value_1, value_2, ... )
Max( value_1, value_2, ... )
Max( value_1, value_2, ... )
max( value_1, value_2, ... )
Max( value_1, value_2, ... )
Description
The Max
function returns the largest value in a list of values.
Types have an order of precedence. When comparing values of different types, they are ranked in the following order, from least to greatest.
The run time of For query "width" errors, the underlying set or page involves more than
100K items. This can happen when using a set function, such as
For example, instead of:
use:
This does mean that if the entire set must be evaluated to arrive at the
correct result, you would have to page through the For query timeout errors, you may specify a larger query timeout via the driver that you are using. |
Examples
The following query executes an array of independent max operations and returns the results in an array. The result array position matches the execution array position. The top operation in the execution array, max of the values 1, 5, and 22, returns a long value of 22 in the top position of the result array.
Arr(LongV(22), LongV(3), LongV(12), LongV(10))
[22 3 12 10]
[22, 3, 12, 10]
[ 22, 3, 12, 10 ]
[22, 3, 12, 10]
[ 22, 3, 12, 10 ]
The following query uses the same approach as the previous query to
demonstrate using Max
with various types of values:
Arr(StringV(D), StringV(A), FaunaTime(1980-01-01T00:00:00Z), FaunaDate(1970-01-01 12:00:00 AM), StringV(A), BooleanV(True), ObjectV(x: LongV(11)), Arr(StringV(C)), Arr(StringV(X)))
[D A {0 62451129600 <nil>} {0 62135596800 <nil>} A true map[x:11] [C] [X]]
["D", "A", 1980-01-01T00:00:00Z, 1970-01-01, "A", true, {x: 11}, ["C"], ["X"]]
[
'D',
'A',
Time("1980-01-01T00:00:00Z"),
Date("1970-01-01"),
'A',
true,
{ x: 11 },
[ 'C' ],
[ 'X' ]
]
['D', 'A', FaunaTime('1980-01-01T00:00:00Z'), datetime.date(1970, 1, 1), 'A', True, {'x': 11}, ['C'], ['X']]
[
'D',
'A',
Time("1980-01-01T00:00:00Z"),
Date("1970-01-01"),
'A',
true,
{ x: 11 },
[ 'C' ],
[ 'X' ]
]
Is this article helpful?
Tell Fauna how the article can be improved:
Visit Fauna's forums
or email docs@fauna.com
Thank you for your feedback!