← Back to Stormify Documentation

MultiAggregator

A multi-value aggregator built from a chain of aggregation requests over a PagedListBase. Each chain method adds another expression to the generated SELECT list. execute returns a Map<String, Any?> keyed by the alias of each added aggregation.

Obtained by chaining additional methods onto a SingleAggregator — conceptually the "two or more aggregations" view. Acquire via PagedListBase.getAggregator and then chain .sum(…), .avg(…), … Aggregations respect the parent list's constraints and per-column filters.

val row = list.getAggregator()
.sum("revenue", "total")
.avg("revenue", "average")
.count("*", "cnt")
.execute()
val total = row["total"] as BigDecimal

Properties

Link copied to clipboard

The SQL that execute will run against the database.

Functions

Link copied to clipboard
fun avg(path: String, alias: String? = null): MultiAggregator

Adds AVG(path) with an optional alias.

fun avg(path: ScalarPath, alias: String? = null): MultiAggregator

Adds AVG(path) using a type-safe ScalarPath with an optional alias.

Link copied to clipboard
fun count(path: String, alias: String? = null): MultiAggregator

Adds COUNT(path) with an optional alias. Pass "*" for COUNT(*).

fun count(path: ScalarPath, alias: String? = null): MultiAggregator

Adds COUNT(path) using a type-safe ScalarPath with an optional alias.

Link copied to clipboard

Adds COUNT(DISTINCT path) with an optional alias.

Adds COUNT(DISTINCT path) using a type-safe ScalarPath with an optional alias.

Link copied to clipboard
fun execute(): Map<String, Any?>

Executes the chained aggregations in a single query and returns a map keyed by each added aggregation's alias. The map values are the raw column results — callers are responsible for any type coercion.

Link copied to clipboard
fun max(path: String, alias: String? = null): MultiAggregator

Adds MAX(path) with an optional alias.

fun max(path: ScalarPath, alias: String? = null): MultiAggregator

Adds MAX(path) using a type-safe ScalarPath with an optional alias.

Link copied to clipboard
fun min(path: String, alias: String? = null): MultiAggregator

Adds MIN(path) with an optional alias.

fun min(path: ScalarPath, alias: String? = null): MultiAggregator

Adds MIN(path) using a type-safe ScalarPath with an optional alias.

Link copied to clipboard
fun raw(expression: String, alias: String? = null): MultiAggregator

Adds an arbitrary SQL expression as a standalone aggregation column. The expression is emitted verbatim — callers are responsible for writing safe, dialect-compatible SQL.

Link copied to clipboard
fun sum(path: String, alias: String? = null): MultiAggregator

Adds SUM(path) with an optional alias.

fun sum(path: ScalarPath, alias: String? = null): MultiAggregator

Adds SUM(path) using a type-safe ScalarPath with an optional alias.