+ Start a Discussion
SuAkSuAk 

Illegal assignment from List<AggregateResult> to List<Deployment_Item__c>

Hi All - I am getting the follwoing error : Illegal assignment from List<AggregateResult> to List<Deployment_Item__c> for the code in Apex : 

 List<Deployment_Item__c> DIList = [SELECT Count(Member_Value__c),    Name_tag__c
                                             FROM  Deployment_Item__c
                                           WHERE Created_Date__c = Today
                                           GROUP BY Name_tag__c ];
Kindly help me to resolve this . 

Thanks,
Sujatha.M

 
Leonardi KohLeonardi Koh
Hi Sujatha,

When you use an aggregate function (for example, MAX, MIN, or COUNT that you used above) the query will not be returning the normal SObject records but instead it will return aggregateResult

https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_calls_query_aggregateresult.htm