You need to sign in to do that
Don't have an account?
aolivencia
Query error "Field must be grouped or aggregated: Id"
Hi, I'm getting a strange error when I try to save my class file:
Field must be grouped or aggregated: Id
The error is somewhere here:
for (AggregateResult iter : [
Select
Id,
SUM(ReleaseAmount__c)
from myObj__c Where nObj__c = 'a0DA00000012fbMMAQ'
]) { .........................
Any idea ?
All Answers
You just need to use the agrregate function as the error describes
Select Id,SUM(ReleaseAmount__c) from myObj__c Where nObj__c = 'a0DA00000012fbMMAQ' group by Id
That is it. Hope this is what you are looking for
Thanks.
Documentation says: "You can use these functions without using a GROUP BY clause" : http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_soql_select_agg_functions.htm
Maybe it works just with one aggregated fetched field