0
    public class Temp {
    public static void b(){
        AggregateResult[] groupedResults = [Select owner.email from Opportunity where LastModifiedDate <  LAST_N_DAYS:10 group by owner.email];

        for (AggregateResult ar : groupedResults)  {
            System.debug('owner email' + ar.get('owner.email'));
        }
    }
}

Here ar.get('owner.email') this is not working giving an error like this enter image description here

Please help

1 Answer 1

0

Use an alias for the field in the aggregate soql as shown below:

Select owner.email eml from Opportunity where LastModifiedDate <  LAST_N_DAYS:10 group by owner.email

and use the alias in aggregate result get statement

ar.get('eml')
2
  • but alias only work on aggregate functions
    – Gopal
    Apr 21, 2020 at 10:47
  • Yes, field aliasing work only on aggregate SOQL. In your case this should solve the error.
    – arut
    Apr 21, 2020 at 13:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .