count
Apply COUNT() function to a field.
public Query count(String field)
field: API name of the field. Can also be a field of a parent, e.g. 'Owner.Name'.
new Query('Account').
count('Id');public Query count(String field, String alias)
field: API name of the field. Can also be a field of a parent, e.g. 'Owner.Name'.
alias: The alias set to the aggregate function.
new Query('Account').
count('Id', 'idCount');countDistinct
Apply COUNT_DISTINCT() function to a field.
public Query countDistinct(String field)
field: API name of the field. Can also be a field of a parent, e.g. 'Owner.Name'.
new Query('Account').
countDistinct('Id');public Query countDistinct(String field, String alias)
field: API name of the field. Can also be a field of a parent, e.g. 'Owner.Name'.
alias: The alias set to the aggregate function.
new Query('Account').
countDistinct('Id', 'idCount');max
Apply MAX() function to a field
public Query max(String field)
field: API name of the field. Can also be a field of a parent, e.g. 'Owner.Name'.
new Query('Account').
max('Id');public Query max(String field, String alias)
field: API name of the field. Can also be a field of a parent, e.g. 'Owner.Name'.
alias: The alias set to the aggregate function.
new Query('Account').
max('NumberOfEmployees', 'maxEmployees');min
Apply MIN() function to a field
public Query min(String field)
field: API name of the field. Can also be a field of a parent, e.g. 'Owner.Name'.
new Query('Account').
min('Id');public Query min(String field, String alias)
field: API name of the field. Can also be a field of a parent, e.g. 'Owner.Name'.
alias: The alias set to the aggregate function.
new Query('Account').
min('NumberOfEmployees', 'minEmployees');avg
Apply AVG() function to a field
public Query avg(String field)
field: API name of the field. Can also be a field of a parent, e.g. 'Owner.Name'.
new Query('Account').
avg('Id');public Query avg(String field, String alias)
field: API name of the field. Can also be a field of a parent, e.g. 'Owner.Name'.
alias: The alias set to the aggregate function.
new Query('Account').
avg('NumberOfEmployees', 'avgEmployees');sum
Apply SUM() function to a field
public Query sum(String field)
field: API name of the field. Can also be a field of a parent, e.g. 'Owner.Name'.
new Query('Account').
sum('Id');public Query sum(String field, String alias)
field: API name of the field. Can also be a field of a parent, e.g. 'Owner.Name'.
alias: The alias set to the aggregate function.
new Query('Account').
sum('NumberOfEmployees', 'sumEmployees');