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
jdenningjdenning 

Aggregate Functions returning blank results

I recently updated to 19.0 of the IDE from 16.0 and basic aggregrate queries are returning blank results:


SELECT Amount FROM Opportunity returns results
SELECT AVG(Amount) FROM Opportunity returns an empty result

Is there something I'm missing?

Pradeep_NavatarPradeep_Navatar

Please find below a sample code :

 

AggregateResult[] groupedResults = [SELECT CampaignId, AVG(Amount) FROM Opportunity GROUP BY CampaignId];

                                                System.debug('Average amount' + groupedResults[0]);

            for (AggregateResult ar : groupedResults) 

                                                {

                                                                System.debug('Campaign ID' + ar.get('CampaignId'));

                                                                System.debug('Average amount' + ar.get('expr0'));

            }

 

Hope this helps.

jdenningjdenning

Thanks for the reply. it works as expected in code, but when trying to run the query with the salesforce.schema, it returns the CampaignId with an empty expr0.