QBAggregates
Overview
The QBAggregates
class provides a collection of aggregate functions that can be utilized within a QBSelect
query. These functions enable the creation of expressions for common operations such as averages, counts, maximums, minimums, and sums. They are designed to work within query results or as part of grouping and filtering logic.
Key methods include avg
, count
, max
, min
, and sum
, which allow you to compute aggregate values for specific columns or expressions. Additionally, the parent
and root
properties give access to the parent query or table clause, facilitating complex query structures and subqueries.
For more information about constructing and executing queries, refer to QBSelect section of the documentation.
Properties Summarized
Methods Summarized
Properties Detailed
parent
Get query builder parent table clause, this may be a query or a join clause.
Type QBSelect
Sample
root
Get query builder parent.
Type QBSelect
Sample
Methods Detailed
avg({Object})
Create avg(value) expression
Parameters
Object {Object} aggregee - The column or expression to calculate the average for.
Returns: QBColumn A QBAggregate object representing the average operation for the specified aggregee.
Sample
count()
Create count(*) expression
Returns: QBColumn A QBAggregate object representing the count operation.
Sample
count({Object})
Create count(value) expression
Parameters
Object {Object} aggregee - The column, expression, or value to count. Can also be a special value like "*" for counting all rows.
Returns: QBColumn A QBAggregate object representing the count operation with the specified aggregee.
Sample
max({Object})
Create max(value) expression
Parameters
Object {Object} aggregee - The column or expression to calculate the maximum value for. This can be a specific column or a computed expression.
Returns: QBColumn A QBAggregate object representing the maximum value operation for the specified aggregee.
Sample
min({Object})
Create min(value) expression
Parameters
Object {Object} aggregee - The column or expression to calculate the minimum value for. This can be a specific column or a computed expression.
Returns: QBColumn A QBAggregate object representing the minimum value operation for the specified aggregee.
Sample
sum({Object})
Create sum(value) expression
Parameters
Object {Object} aggregee - The column or expression to calculate the sum for. This can be a specific column or a computed expression.
Returns: QBColumn A QBAggregate object representing the sum operation for the specified aggregee.
Sample
Last updated