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