function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SumitkSumitk 

SOQL Apex error

User-added imagewhy am I getting this error?
Best Answer chosen by Sumitk
Footprints on the MoonFootprints on the Moon
Hi Sumitk,
The error for your SOQL query is because, you are grouping both Krow__Account__r.Name and Krow__Account__c without aggregating.
You must use a GROUP BY clause if your query uses a LIMIT clause and an "aggregated" function.
Since you are not aggregating (SUM/COUNT/MIN/MAX) anything, this error is occuring.

To solve- Either aggregate some field and group them OR remove the GROUP BY clause.

Reference - https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_group_by_considerations.htm

Hope this helps!

All Answers

SumitkSumitk
Also I want to know how to write this code independent of package namespace.
Footprints on the MoonFootprints on the Moon
Hi Sumitk,
The error for your SOQL query is because, you are grouping both Krow__Account__r.Name and Krow__Account__c without aggregating.
You must use a GROUP BY clause if your query uses a LIMIT clause and an "aggregated" function.
Since you are not aggregating (SUM/COUNT/MIN/MAX) anything, this error is occuring.

To solve- Either aggregate some field and group them OR remove the GROUP BY clause.

Reference - https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_group_by_considerations.htm

Hope this helps!
This was selected as the best answer