You need to sign in to do that
Don't have an account?

Aggregate Results
I'm trying to figure out how to use aggregate results and just can't seem to get it. I've copied this exact statement from the Apex Code Developer's Guide into an otherwise valid class:
AggregateResult[] groupedResults = [SELECT CampaignId, AVG(Amount) test, FROM Opportunity GROUP BY CampaignId];
I get the error "Invalid Type: AgregateResult".
Obviously, I'm missing the boat somewhere. Can anyone enlighten me about what I'm doing wrong?
Thanks.
All Answers
My class had not been set to Version 18. Once I did that, it worked.
Thanks!
Opps. Spoke too soon.
Once I changed to Version 18, it compiled without anything in the "Problems" tab. Hence, i thought I was OK. However, I just noticed that there is a red X error in the margin which has a popup tooltip reading:
expecting "from" found ''
That doesn't seem to make any sense to me.
Any clues?
You have a bonus comma before your FROM:
SELECT CampaignId, AVG(Amount) test, FROM Opportunity
remove the comma after 'test'.