Aggregates
The query builder also provides a variety of aggregate methods such as count
, max
, min
, and sum
. These methods take the headache out of setting up these common aggregate functions.
When executing any of the aggregate functions, any where
restrictions on your query will still be applied.
Instead of returning a query, these methods return a simple value.
exists
Name | Type | Required | Default | Description |
options | struct |
|
| Any additional |
Returns true
if the query returns any rows. Returns false
otherwise.
count
Name | Type | Required | Default | Description |
column | string |
|
| The column on which to count records. |
options | struct |
|
| Any additional |
Returns an integer number of rows returned by the query.
max
Name | Type | Required | Default | Description |
column | string |
| The column on which to find the max. | |
options | struct |
|
| Any additional |
Returns the maximum value for the given column.
min
Name | Type | Required | Default | Description |
column | string |
| The column on which to find the min. | |
options | struct |
|
| Any additional |
Returns the minimum value for the given column.
sum
Name | Type | Required | Default | Description |
column | string |
| The column to sum. | |
options | struct |
|
| Any additional |
Returns the sum of all returned rows for the given column.
sumRaw
Name | Type | Required | Default | Description |
column | string |
| The column to sum. | |
options | struct |
|
| Any additional |
Returns the sum of all returned rows for the expression.
columnList
Name | Type | Required | Default | Description |
asQuery | boolean |
|
| Flag to retrieve the columnList as a query instead of an array. |
datasource | string |
| Optional datasource to from which to retrieve the columnList. |
Retrieves the columns for the configured table.