MAX

The maximum value in the time window.

Syntax

MAX(VALUE)

Arguments

VALUE: An expression of any type (NUMBER/STRING/INSTANT) that can be ordered. ‌

Returns

The result type matches the type of the argument.

Example

Data

[
   {
      "user":"A01",
      "level":1,
      "score":25
   },
   {
      "user":"A01",
      "level":2,
      "score":48
   },
   {
      "user":"A01",
      "level":2,
      "score":81
   },
   {
      "user":"B02",
      "level":1,
      "score":23
   },
   {
      "user":"B02",
      "level":1,
      "score":29
   }
]

Query

Find the highest score of each user/level:

SELECT
   data.level AS level:DOUBLE,
   data.user AS user:STRING,
   MAX(data.score) AS max_data_score:BIGINT 
FROM
   "MAX_SAMPLE_DATA - json" 
GROUP BY
   data.level,
   data.user

Results

{
  "level": 1,
  "user": "A01",
  "max_data_score": 25
}{
  "level": 2, 
  "user": "A01", 
  "max_data_score": 81
}{
  "level": 1, 
  "user": "B02", 
  "max_data_score": 29
}

MIN MAX_BY MAX_EACH MAX_TIME_SERIES

Dialog

Last updated