-
Notifications
You must be signed in to change notification settings - Fork 0
The Soql.Aggregation Class
Jason Siders edited this page Jul 4, 2025
·
4 revisions
Represents an aggregate expression in a SOQL query. For example, COUNT(Id) numRecords. This class implements Soql.Selectable, and can be used in addSelect methods. This can also be with addHaving methods when making an aggregate query.
Each Soql.Aggregation is comprised of the following properties:
- (always) a
Soql.Function(ex.,COUNT) - (usually) a field (ex.,
Id) - (optionally) An alias (ex,
numRecords)
// "COUNT()"
Soql.Aggregation agg1 = new Soql.Aggregation(Soql.Function.COUNT);
// "CALENDAR_YEAR(CreatedDate)
Soql.Aggregation agg2 = new Soql.Aggregation(Soql.Function.CALENDAR_YEAR, Account.CreatedDate);
// "MAX(CreatedDate) lastCreated"
Soql.Aggregation agg3 = new Soql.Aggregation(Soql.Function.MAX, Account.CreatedDate)?.withAlias('lastCreated');Soql.Aggregation(Soql.Function, String innerFieldName)Soql.Aggregation(Soql.Function, SObjectField field)Soql.Aggregation(Soql.Function, Soql.ParentField field)Soql.Aggregation(Soql.Function)
Adds an alias to the aggregation. Ex., numRecords.
Soql.Aggregation withAlias(String alias)
- Generating Test Records
- Dml
- Soql
- Cmdt
- Plugins
- DatabaseLayer
- Dml
- MockDml
- MockRecord
- Cmdt
- MockCmdt
- MockSoql
-
Soql
- Soql.AggregateResult
- Soql.Aggregation
- Soql.Binder
- Soql.Builder
- Soql.Condition
- Soql.ConditionalLogic
- Soql.Criteria
- Soql.Cursor
- Soql.Function
- Soql.InnerQuery
- Soql.InvalidParameterValueException
- Soql.LogicType
- Soql.NullOrder
- Soql.Operation
- Soql.Operator
- Soql.ParentField
- Soql.PreAndPostProcessor
- Soql.QueryLocator
- Soql.Request
- Soql.Scope
- Soql.Selectable
- Soql.SortDirection
- Soql.SortOrder
- Soql.Subquery
- Soql.TypeOf
- Soql.Usage
- Soql.WhenClause