QBAggregate
Overview
The QBAggregate
class represents aggregate expressions, such as count
, min
, and max
, within a QBSelect
query. It provides a range of methods and properties for constructing and manipulating aggregate expressions, allowing for customization of query results and conditions.
Aggregates can be used to calculate summaries, apply mathematical functions, or manipulate data within a query. Properties like count
, sum
, and avg
allow direct creation of aggregate expressions, while others like abs
or round
perform mathematical operations. Sorting and conditional operations can also be applied using properties such as asc
, desc
, and isNull
.
Methods extend the functionality of aggregates by enabling operations like comparison (eq
, between
, like
), mathematical manipulation (plus
, minus
, mod
), and substring extraction (substring
). These features provide fine-grained control over how aggregate data is computed and retrieved.
The QBAggregate
class integrates with query builder constructs like QBColumn, QBCondition, and QBSort, enabling complex query logic and data transformations.
Properties Summarized
Methods Summarized
The flags are a bit pattern consisting of 1 or more of the following bits: - JSColumn.
Properties Detailed
abs
Create abs(column) expression
Type QBColumn
Sample
asc
Create an ascending sort expression
Type QBSort
Sample
avg
Create an aggregate average expression.
Type QBColumn
Sample
bit_length
Create bit_length(column) expression
Type QBColumn
Sample
ceil
Create ceil(column) expression
Type QBColumn
Sample
count
Create an aggregate count expression.
Type QBColumn
Sample
day
Extract day from date
Type QBColumn
Sample
desc
Create an descending sort expression
Type QBSort
Sample
distinct
Add a distinct qualifier to the aggregate
Type QBColumn
Sample
floor
Create floor(column) expression
Type QBColumn
Sample
hour
Extract hour from date
Type QBColumn
Sample
isNull
Compare column with null.
Type QBCondition
Sample
len
Create length(column) expression
Type QBColumn
Sample
lower
Create lower(column) expression
Type QBColumn
Sample
max
Create an aggregate max expression.
Type QBColumn
Sample
min
Create an aggregate min expression.
Type QBColumn
Sample
minute
Extract minute from date
Type QBColumn
Sample
month
Extract month from date
Type QBColumn
Sample
not
Create a negated condition.
Type QBColumn
Sample
parent
Get query builder parent table clause, this may be a query or a join clause.
Type QBTableClause
Sample
root
Get query builder parent.
Type QBSelect
Sample
round
Create round(column) expression
Type QBColumn
Sample
second
Extract second from date
Type QBColumn
Sample
sqrt
Create sqrt(column) expression
Type QBColumn
Sample
sum
Create an aggregate sum expression.
Type QBColumn
Sample
trim
Create trim(column) expression
Type QBColumn
Sample
upper
Create upper(column) expression
Type QBColumn
Sample
year
Extract year from date
Type QBColumn
Sample
Methods Detailed
between(value1, value2)
Compare column to a range of 2 values or other columns.
Parameters
Returns: QBCondition
Sample
cast(type)
Create cast(column, type) expression
Parameters
String type string type, see QUERY_COLUMN_TYPES
Returns: QBColumn
Sample
concat(arg)
Concatename with value
Parameters
Object arg valeu to concatenate with
Returns: QBColumn
Sample
divide(arg)
Divide by value
Parameters
Object arg nr to divide by
Returns: QBColumn
Sample
eq(value)
Compare column with a value or another column. Operator: equals
Parameters
Object value ;
Returns: QBCondition
Sample
ge(value)
Compare column with a value or another column. Operator: greaterThanOrEqual
Parameters
Object value ;
Returns: QBCondition
Sample
getFlags()
The flags are a bit pattern consisting of 1 or more of the following bits: - JSColumn.UUID_COLUMN - JSColumn.EXCLUDED_COLUMN - JSColumn.TENANT_COLUMN
Returns: Number
getTypeAsString()
Column type as a string
Returns: String
gt(value)
Compare column with a value or another column. Operator: greaterThan
Parameters
Object value ;
Returns: QBCondition
Sample
isin(query)
Compare column with subquery result.
Parameters
QBPart query subquery
Returns: QBCondition
Sample
isin(values)
Compare column with values.
Parameters
Array values array of values
Returns: QBCondition
Sample
isin(customQuery, args)
Compare column with custom query result.
Parameters
Returns: QBCondition
Sample
le(value)
Compare column with a value or another column. Operator: lessThanOrEqual
Parameters
Object value ;
Returns: QBCondition
Sample
like(pattern)
Compare column with a value or another column. Operator: like
Parameters
Object pattern the string value of the pattern
Returns: QBCondition
Sample
like(pattern, escape)
Compare column with a value or another column. Operator: like, with escape character
Parameters
Returns: QBCondition
Sample
locate(arg)
Create locate(arg) expression
Parameters
Object arg string to locate
Returns: QBColumn
Sample
locate(arg, start)
Create locate(arg, start) expression
Parameters
Returns: QBColumn
Sample
lt(value)
Compare column with a value or another column. Operator: lessThan
Parameters
Object value ;
Returns: QBCondition
Sample
minus(arg)
Subtract value
Parameters
Object arg nr to subtract
Returns: QBColumn
Sample
mod(arg)
Create mod(arg) expression
Parameters
Object arg mod arg
Returns: QBColumn
Sample
multiply(arg)
Multiply with value
Parameters
Object arg nr to multiply with
Returns: QBColumn
Sample
nullif(arg)
Create nullif(arg) expression
Parameters
Object arg object to compare
Returns: QBColumn
Sample
plus(arg)
Add up value
Parameters
Object arg nr to add
Returns: QBColumn
Sample
substring(pos)
Create substring(pos) expression
Parameters
Number pos ;
Returns: QBColumn
Sample
substring(pos, len)
Create substring(pos, len) expression
Parameters
Returns: QBColumn
Sample
Last updated