Last updated
Was this helpful?
Last updated
Was this helpful?
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 section of the documentation.
Get query builder parent table clause, this may be a query or a join clause.
Sample
Get query builder parent.
Sample
Create avg(value) expression
Parameters
Sample
Create count(*) expression
Sample
Create count(value) expression
Parameters
Sample
Create max(value) expression
Parameters
Sample
Create min(value) expression
Parameters
Sample
Create sum(value) expression
Parameters
Sample
Type
Type
{Object} aggregee - The column or expression to calculate the average for.
Returns: A QBAggregate object representing the average operation for the specified aggregee.
Returns: A QBAggregate object representing the count operation.
{Object} aggregee - The column, expression, or value to count. Can also be a special value like "*" for counting all rows.
Returns: A QBAggregate object representing the count operation with the specified aggregee.
{Object} aggregee - The column or expression to calculate the maximum value for. This can be a specific column or a computed expression.
Returns: A QBAggregate object representing the maximum value operation for the specified aggregee.
{Object} aggregee - The column or expression to calculate the minimum value for. This can be a specific column or a computed expression.
Returns: A QBAggregate object representing the minimum value operation for the specified aggregee.
{Object} aggregee - The column or expression to calculate the sum for. This can be a specific column or a computed expression.
Returns: A QBAggregate object representing the sum operation for the specified aggregee.
Get query builder parent table clause, this may be a query or a join clause.
Get query builder parent.
Create avg(value) expression
Create count(*) expression
Create count(value) expression
Create max(value) expression
Create min(value) expression
Create sum(value) expression