Upsolver
Search…
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

1
[
2
{
3
"user":"A01",
4
"level":1,
5
"score":25
6
},
7
{
8
"user":"A01",
9
"level":2,
10
"score":48
11
},
12
{
13
"user":"A01",
14
"level":2,
15
"score":81
16
},
17
{
18
"user":"B02",
19
"level":1,
20
"score":23
21
},
22
{
23
"user":"B02",
24
"level":1,
25
"score":29
26
}
27
]
Copied!

Query

Find the highest score of each user/level:
1
SELECT
2
data.level AS level:DOUBLE,
3
data.user AS user:STRING,
4
MAX(data.score) AS max_data_score:BIGINT
5
FROM
6
"MAX_SAMPLE_DATA - json"
7
GROUP BY
8
data.level,
9
data.user
Copied!

Results

1
{
2
"level": 1,
3
"user": "A01",
4
"max_data_score": 25
5
}{
6
"level": 2,
7
"user": "A01",
8
"max_data_score": 81
9
}{
10
"level": 1,
11
"user": "B02",
12
"max_data_score": 29
13
}
Copied!

Dialog