English | 简体中文

api-docs / org.ktorm.entity / eachSumBy

eachSumBy

inline fun <E : Any, T : BaseTable<E>, K : Any, C : Number> EntityGrouping<E, T, K>.eachSumBy(
    columnSelector: (T) -> ColumnDeclaring<C>
): Map<K?, C?>
(source code)

Group elements from the source sequence by key and sum the columns or expressions provided by the columnSelector
function for elements in each group.

The key for each group is provided by the EntityGrouping.keySelector function, and the generated SQL is like:
select key, sum(column) from source group by key.

Parameters

columnSelector - a function that accepts the source table and returns the column or expression for summing.

Return
a Map associating the key of each group with the summing result in the group.