Aggregate functions in SOQL work much like their SQL counterparts. They are applied to fields in the
SELECT list. After you include an aggregate function in a query, nonaggregate fields in the same query are not allowed. The six aggregate functions available in SOQL are
AVG—Calculates an average of the values in a numeric field.
COUNT—Counts the values in a numeric, date, or string field, including duplicate values but not nulls. Unlike all other aggregate functions, the argument to
COUNT is optional.