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.
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