function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Hari.gsHari.gs 

AggregateResult issue

Hi,

 

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) 
tukmoltukmol

the error told you what the type should be:

 

for(AggregateResult ppd : pp) {}