Aggregate Functions
COUNT
Returns the number of rows matching the query criteria.
SELECT COUNT(*) FROM Deals WHERE UserName = 'Bob'
COUNT(DISTINCT)
Returns the number of distinct, non-null field values matching the query criteria.
SELECT COUNT(DISTINCT Id) AS DistinctValues FROM Deals WHERE UserName = 'Bob'
AVG
Returns the average of the column values.
SELECT UserEmail, AVG(AnnualRevenue) FROM Deals WHERE UserName = 'Bob' GROUP BY UserEmail
MIN
Returns the minimum column value.
SELECT MIN(AnnualRevenue), UserEmail FROM Deals WHERE UserName = 'Bob' GROUP BY UserEmail
MAX
Returns the maximum column value.
SELECT UserEmail, MAX(AnnualRevenue) FROM Deals WHERE UserName = 'Bob' GROUP BY UserEmail
SUM
Returns the total sum of the column values.
SELECT SUM(AnnualRevenue) FROM Deals WHERE UserName = 'Bob'