MIN
Represents the SQL MIN() aggregate or scalar function.
As an aggregate function,
MIN(column)returns the minimum non-NULL value of all values in a group.As a scalar function,
MIN(value1, value2, ...)returns the argument with the minimum value.
The type of the result is the same as the type of the input column(s).
Example
// Aggregate: Find the minimum track length
// SELECT MIN(length) FROM Tracks;
val cursor1 =
Tracks
.select(MIN(Tracks.length))
.execute()
println(cursor1[MIN(Tracks.length)])
cursor1.close()
// Aggregate with DISTINCT:
// SELECT MIN(DISTINCT length) FROM Tracks;
val minDistinctLength = MIN(Tracks.length, distinct = true)
val cursor2 =
Tracks
.select(minDistinctLength)
.execute()
println(cursor2[minDistinctLength])
cursor2.close()
// Scalar: Find the minimum of two literal values
// SELECT MIN(10, 20);
val cursor3 =
select(
MIN(
IntLiteral(10),
IntLiteral(20),
),
).execute()
println(cursor3.getInt(0))
cursor3.close()Content copied to clipboard
Return
A KQLiteColumn representing the minimum value, with the same type as the input column(s).
Author
MOHAMMAD AZIM ANSARI
Parameters
columns
Columns or values. If provided, the function acts as a scalar MIN across all provided arguments.
distinct
If true, only DISTINCT values in the column are considered. Defaults to false.