FQL v4 will be decommissioned on June 30, 2025. Ensure that you complete your migration from FQL v4 to FQL v10 by that date. For more details, review the migration guide. Contact support@fauna.com with any questions. |
Max
This reference topic applies to FQL v4. Go to this page for the latest FQL v10 reference topics. |
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.
-
Number (integers and decimals: 0.5 < 1 < 1.5 < 2)
-
Byte
-
String
-
Array (ordered lexically, like strings)
-
Object (ordered lexically, like strings)
-
Reference
-
Timestamp
-
Date
-
Boolean (false < true)
-
Null
With this precedence, Strings are always larger than Numbers.
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. |
Parameters
Parameter | Type | Definition and Requirements |
---|---|---|
|
List of Values. |
A single Value or a list of Values. |
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.
[ 22, 3, 12, 10 ]
[22, 3, 12, 10]
[22 3 12 10]
Arr(LongV(22), LongV(3), LongV(12), LongV(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:
[
'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 {0 62451129600 <nil>} {0 62135596800 <nil>} A true map[x:11] [C] [X]]
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',
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!