MIN

The minimum value in the time window.

Syntax

MIN(VALUE)

Arguments

VALUE: An expression of any type (INTEGER/STRING/DATE) 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 lowest score of each user/level:

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

Results

{
   "min_data_score":48,
   "level":2,
   "user":"A01"
}{
   "min_data_score":23,
   "level":1,
   "user":"B02"
}{
   "min_data_score":25,
   "level":1,
   "user":"A01"
}

MAX MIN_BY MIN_EACH MIN_TIME_SERIES

Dialog

Last updated