average

open infix fun <T : Number> Field<Into, T>.average(value: Value<From, Number>)(source)
open infix fun <T : Number> KProperty1<Into, T>.average(value: Value<From, Number>)(source)

Calculates and returns the collective average of numeric values. Non-numeric values are ignored.

If all elements are non-numeric, null is returned.

Example

class User(
val name: String,
val balance: Int,
)

class Result(
val totalBalance: Int,
)

users.aggregate()
.group {
Result::totalBalance average of(User::balance)
}

External resources