STRING_ AGG
fun STRING_AGG(column: KQLiteColumn<*>, separator: String, distinct: Boolean = false): KQLiteColumn<String>
Represents the SQL STRING_AGG() aggregate function.
This function returns a single string consisting of all non-NULL values from a group, concatenated together, with a specified separator.
Example
// Concatenate all employee first names with a " | " separator.
// SELECT STRING_AGG(firstName, ' | ') FROM Employees;
val allNames = STRING_AGG(Employees.firstName, " | ")
val cursor =
Employees
.select(allNames)
.execute()
println(cursor[allNames])
cursor.close()
// Concatenate only distinct cities with a comma and space.
// SELECT STRING_AGG(DISTINCT city, ', ') FROM Employees;
val distinctCities = STRING_AGG(Employees.city, ", ", distinct = true)
val cursor2 =
Employees
.select(distinctCities)
.execute()
println(cursor2[distinctCities])
cursor2.close()Content copied to clipboard
Return
A KQLiteColumn representing the concatenated string. The result is NULL if the group is empty.
Author
MOHAMMAD AZIM ANSARI
Parameters
column
The column whose values are to be concatenated.
separator
The string to use as a separator between concatenated values.
distinct
If true, only DISTINCT (unique) non-NULL values in the column are concatenated. Defaults to false.