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
:) :) :) :) :):) :) :) :) :) 

SOQL Aggregate functions LIMIT

I could have searched on governor limit guide but it's eaiser to ask on developer forums. How many Aggregate functions I can use per soql query.

[Select count(id), count(name).........{N}....from account]
@Karanraj@Karanraj
There is no documented limit You can include multiple COUNT(fieldName) items in a SELECT clause. Note that SOQL statement is length must be less than 20,000 characters.
nagendra 6989nagendra 6989
Hi,

Aggregate functions in SOQL, such as SUM() and MAX(), allow you to roll up and summarize your data in a query. 

As per the salesforce documentation, Queries that include aggregate functions are subject to the same governor limits as other SOQL queries. So you can use # agregate functions == #fields.

Statement Character Limit — By default, SOQL statements cannot exceed 20,000 characters in length. For SOQL statements that exceed this maximum length, the API returns a MALFORMED_QUERY exception code; no result rows are returned.

Long, complex SOQL statements, such as statements that contain many formula fields, can sometimes result in a QUERY_TOO_COMPLICATED error. The error occurs because the statement is expanded internally when processed by Salesforce, even though the original SOQL statement is under the 20,000 character limit. To avoid this, reduce the complexity of your SOQL statement.

Please let me know if this helps you .........................

Best Regards
Nagendra.P
9848950830