+ Start a Discussion

AggregateResult issue



I have an array of  type AggregateResult. How to loop through this?


For Eg:


AggregateResult[] pp = [select min(Purchase_Date__c)Purchase_Date__c, Account__c from Purchased_Products_del__c group by Account__c];


When i loop using


for(Purchased_Products_del__c ppd : pp) {} shows an error


"Save error: Loop variable must be of type SOBJECT:AggregateResult"


Please help


Thanks and Regards

Hari G S




Best Answer chosen by Admin (Salesforce Developers) 

the error told you what the type should be:


for(AggregateResult ppd : pp) {}