AggregateFunctionBuilder
AggregateFunctionBuilder is returned by aggregate function calls from the FunctionModule. It provides methods for adding modifiers like distinct, filter, order by, and over clauses to aggregate functions.
Type Parameters
The database schema type
The table references available in the current query context
The output type of the aggregate function
Methods
as
Returns an aliased version of the function.The alias name for the aggregate function result
as "the_alias" to the end of the SQL, this method also provides strict typing.
Example:
distinct
Adds adistinct clause inside the function.
orderBy
Adds anorder by clause inside the aggregate function.
Column or expression to order by
Optional order modifiers (e.g.,
asc, desc, nulls handling)clearOrderBy
Removes all order by clauses from the aggregate function.withinGroupOrderBy
Adds awithin group clause with a nested order by clause after the function.
Column or expression to order by
Optional order modifiers
filterWhere
Adds afilter clause with a nested where clause after the function.
Left-hand side column reference
Comparison operator
Right-hand side value or expression
Alternative: full expression or factory function
filterWhereRef
Adds afilter clause with a nested where clause after the function, where both sides of the operator are references to columns.
Left-hand side column reference
Comparison operator
Right-hand side column reference
over
Adds anover clause (window functions) after the function.
Optional callback that returns an OverBuilder with partition by and order by clauses
$call
Simply calls the provided function passingthis as the only argument. $call returns what the provided function returns.
Function to call with this builder as argument
$castTo
Casts the expression to the given type.The new output type
AggregateFunctionBuilder with a new output type.
$notNull
Omit null from the expression’s type.this with a new output type.
toOperationNode
Converts the builder to an operation node for internal use.Related Types
AliasedAggregateFunctionBuilder
AggregateFunctionBuilder with an alias. The result of calling AggregateFunctionBuilder.as.
The database schema type
The table references
The output type
The alias name
OverBuilderCallback
Callback type for theover method.