You need to sign in to do that
Don't have an account?
Varun Annadata
how to use group by in this soql query?
List<Program_Member_Stage_MVN__c>Pms =[select id,Name,Parent_Program_Member_Stage_MVN__c,Program_Stage_MVN__c,Status_MVN__c,Program_Stage_Name_MVN__c,Stage_Sequence_Number_MVN__c,Activity_Sequence_Number_CTS__c,Parent_Program_Stage__c from Program_Member_Stage_MVN__c where Program_Member_MVN__c=:Pm.id and Status_MVN__c='Not Started' and Parent_Stage__c !='Parent_Stage_MVN' order by Parent_Program_Stage__c,Activity_Sequence_Number_CTS__c];
I am getting this error:
Field must be grouped or aggregated: Id at line 18 column 49.How to bypass this error?
I am getting this error:
Field must be grouped or aggregated: Id at line 18 column 49.How to bypass this error?
Write the field after select statetement on which you want to make group by for e.g
SELECT Parent_Program_Member_Stage_MVN__c,Activity_Sequence_Number_CTS__c from Program_Member_Stage_MVN__c group by Parent_Program_Member_Stage_MVN__c;
Let me know if this solves you problem.
Thanks,
Sukanya Banekar
If you have to use Group by clouse you must have to use aggreaget function like min, max,count, sum. Field which you used in group by clouse must used aggregate function.here is small example
SELECT Description, count(Id), COUNT_DISTINCT(WhatId) FROM Task WHERE WhoId = :contactId GROUP BY Description
Thank you,\
Amol Salve
Salesforce developer
As its is mentioned in the error itself "Field must be grouped or aggregated"
You need to write an aggregate function in your query to make it function.
For ex -