Max

Not available in this language yet.
Max( value_1, value_2, ... )
Max( value_1, value_2, ... )
Max( value_1, value_2, ... )
Not available in this language yet.
Not available in this language yet.
Not available in this language yet.
Max( value_1, value_2, ... )

Description

The Max function returns the largest value in a list of values.

Parameters

Argument Type Definition and Requirements

value

List of values.

A single value or a list of values.

Returns

A value which is the maximum value from the value list.

Examples

The query below 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.

System.out.println(
    client.query(
        Arr(
            Max(Value(1), Value(5), Value(22)),
            Max(Value(1), Value(0), Value(3), Value(-1)),
            Max(Value(-1), Value(12), Value(3), Value(-1)),
            Max(Value(10))
        )
    ).get()
);
client.query([
  q.Max(1, 5, 22),
  q.Max(1, 0, 3, -1),
  q.Max(-1, 12, 3, -1),
  q.Max(10),
]).then((ret) => console.log(ret))
result, err := client.Query(
  f.Arr{
    f.Max(1, 5, 22),
    f.Max(1, 0, 3, -1),
    f.Max(-1, 12, 3, -1),
    f.Max(10)})
println(Await.result(
  client.query(
    Arr(
      Max(1, 5, 22),
      Max(1, 0, 3, -1),
      Max(-1, 12, 3, -1),
      Max(10)
    )
  ),
  5.seconds
))
[
  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:

System.out.println(
    client.query(
        Arr(
          Max("A", "B", "C", "D"),
          Max(Time("1970-01-01T00:00:00Z"), Time("1980-01-01T00:00:00Z")),
          Max(Date("1970-01-01"), Date("1930-01-01"),
          Max("A", 1)
        )
    ).get()
);
client.query([
  q.Max('A', 'B', 'C', 'D'),
  q.Max(q.Time('1970-01-01T00:00:00Z'), q.Time('1980-01-01T00:00:00Z')),
  q.Max(q.Date('1970-01-01'), q.Date('1930-01-01')),
  q.Max('A', 1),
])
.then((ret) => console.log(ret))
result, err := client.Query(
  f.Arr{
    f.Max("A", "B", "C", "D"),
    f.Max(f.Time("1970-01-01T00:00:00Z"), f.Time("1980-01-01T00:00:00Z")),
    f.Max(f.Date("1970-01-01"), f.Date("1930-01-01"),
    f.Max("A", 1)
   })
println(Await.result(
  client.query(
    Arr(
      Max("A", "B", "C", "D"),
      Max(Time("1970-01-01T00:00:00Z"), Time("1980-01-01T00:00:00Z")),
      Max(Date("1970-01-01"), Date("1930-01-01"),
      Max("A", 1)
    )
  ),
  5.seconds
))
["D", 1980-01-01T00:00:00Z, 1970-01-01, "A"]
[ 'D', Time("1980-01-01T00:00:00Z"), Date("1970-01-01"), 'A' ]
[D {0 62451129600 <nil>} {0 62135596800 <nil>} A]
["D", 1980-01-01T00:00:00Z, 1970-01-01, "A"]

Was this article helpful?

We're sorry to hear that.
Tell us how we can improve! documentation@fauna.com

Thank you for your feedback!