Newer Version Available
AggregateResult
This object contains the results returned by a query() if the query contains an aggregate function, such as MAX(). AggregateResult is an sObject, but unlike other sObject objects such as Contact, it is read-only and it is only used for query results.
The QueryResult object has a records field that is an array of sObject records matching your query. For example, the following query returns an array of Contact records in the records field.
When a SOQL query contains an aggregate function, the results are a set of aggregated data instead of an array of records for a standard object, such as Contact. Therefore, the records field returns an array of AggregateResult records.
For more information on aggregate functions, see “Aggregate Functions” in the Salesforce SOQL and SOSL Reference Guide.
Fields
Each AggregateResult object contains a separate field for each of the items in the SELECT list. For the enterprise WSDL, retrieve the result for each item by calling getField() on an AggregateResult object when using WSC client framework. For the partner WSDL, retrieve the result for each item by calling getField() on an sObject object.
See Sample Code—Java and Sample Code—C# for examples that work with the enterprise WSDL.