Retrieving aggregate results in Apex
|
In Apex, we use any aggregate function like the following way:-
First we have to declare a variable of list of Aggregate results, then the query, after that we have to use a loop and get that aggregate value.
LIST<AggregateResult> noOfEmployees = new LIST<AggregateResult> ();
noOfEmployees = [SELECT COUNT(id) noOfEmp FROM Employee__c WHERE salary__c > 25000 ]; for(AggregateResult sobj : noOfEmployees) { |
}
No comments :
Post a Comment