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
rishi jaykar 1rishi jaykar 1 

aggregate query under trigger is it good practice or bad ?

mukesh guptamukesh gupta
Yes, We can use in trigger it's a good practice ,
Aggregate functions in salesforce include AVG(), COUNT(), MIN(), MAX(), SUM().The functions like  SUM() and MAX() in SOQL allow to roll up and summarize the data in a query. The GROUP BY clause in a SOQL query is to avoid iterating through individual query results and used to specify a group of records instead of processing many individual records. 
AVG() - Returns the average value of a numeric field 
COUNT() - Returns the number of rows matching the query criteria 
MIN() - Returns the minimum value of a field 
MAX() - Returns the maximum value of a field 
SUM() - Returns the total sum of a numeric field 

Kindly mark my solution as the best answer if it helps you.

Thanks
Mukesh