You need to sign in to do that
Don't have an account?
Vipin Pulinholy
SOQL Aggregate Error : First error: Field must be grouped or aggregated: Id
Hi Friends,
I am running following query on Batch Apex:
Select Compensation_Bucket_Product__r.Compensation_Bucket_ID__r.Id Comp_Id, Reporting_Segment__r.Id RSC_Id, SUM(PFYE_Sales__c) PYESales, SUM(PFYE_GP__c) PYEGP, SUM(PFYTD_Sales__c) PYTDSales, SUM(PFYTD_GP__c) PYTDGP, SUM(CYFTD_Sales__c) CYTDSales, SUM(CFYTD_GP__c) CYTDGP, SUM(CY_Sales_Run_Rate__c) CYRRSales, SUM(CY_GP_Run_Rate__c) CYRRGP, SUM(NY_Sales_Run_Rate__c) NYRRSales, SUM(NY_GP_Run_Rate__c) NYRRGP, RecordTypeId FROM Compensation_Bucket_Forecast_Items__c GROUP BY Compensation_Bucket_Product__r.Compensation_Bucket_ID__r.Id, Reporting_Segment__r.Id, RecordTypeId HAVING Compensation_Bucket_Product__r.Compensation_Bucket_ID__r.Id <> NULL AND Reporting_Segment__r.Id <> NULL AND RecordTypeId =\''+salesRecId.Id+'\'';
This query runs well in VFcontroler/Eclipse. But if I run on batch Apex I get follwoing Error:
First error: Field must be grouped or aggregated: Id
Could you please help us on fixing this issue.? Where we went worng?
Thanks much for your time.
You are not grouping on Compensations_Bucket_Forecast_Items__c.Id
Try adding that, and see how you go.
Q
Odd. Can you include your batch apex code, and/or share a dev org with your custom objects in so I can connect and try a few things out?