DISTINCT
Represents the SQL DISTINCT keyword used as a function-like wrapper.
This is a helper function to wrap a column with DISTINCT, typically used inside another aggregate function like COUNT or SUM when the distinct parameter is not available or when more complex expressions are needed.
Note: In many KQLite aggregate functions (AVG, COUNT, SUM, etc.), it is more idiomatic to use the distinct = true parameter instead of this wrapper.
Example
// Using the distinct parameter (preferred way)
// SELECT COUNT(DISTINCT city) FROM Employees;
val count1 = COUNT(Employees.city, distinct = true)
// Using the DISTINCT() wrapper function (alternative way)
// SELECT COUNT(DISTINCT(city)) FROM Employees;
val count2 = COUNT(DISTINCT(Employees.city))
val cursor = Employees.select(count2).execute()
println(cursor[count2])
cursor.close()Content copied to clipboard
Return
A KQLiteColumn that represents the original column with the DISTINCT keyword.
Author
MOHAMMAD AZIM ANSARI
Parameters
column
The column to which the DISTINCT keyword should be applied.
Type Parameters
T
The type of the column.