+ Start a Discussion
Binu 8Binu 8 

soql group by error

Hi Team,

I have a custom object which name is Subscription__c and it have a custom field Created_Date__c.

When I am trying to execute this soql this error is occuring. "CALENDAR_YEAR(Created_Date__c) = 2015 GROUP BY Name, Status__c, Subscription_Frequency__c ^ ERROR at Row:1:Column:355 field 'Name' can not be grouped in a query call".

SOQL is,

SELECT Name,Status__c status, SUM(Subscription_Amount__c) amount,SUM(Subscription_Revenue__c) revenue ,
                Subscription_Frequency__c frequency,Ecommerce_Platform__c platform,Subscription_Plan__c plan,CALENDAR_QUARTER(Created_Date__c)quarter,
                CALENDAR_MONTH(Created_Date__c)month FROM Subscription__c WHERE CALENDAR_YEAR(Created_Date__c) = 2015 GROUP BY  Name,Status__c,Subscription_Frequency__c,
Hello Binu,

In your Custom Object ("Subscription__c"). i think Name field is unique ("Auto Number "). and we can't do group by on unique field like id, AutoNumber. because of that compile error is coming in your code.

let me know if you have any question on this.

Thank You,
Hitesh Patel
Email :- hiteshpatel.aspl@gmail.com