Aggregate Functions
Examples of Aggregate Functions
Below are several examples of SQL aggregate functions.
COUNT(DISTINCT)
Returns the number of distinct, non-null field values matching the query criteria.
SELECT COUNT(DISTINCT Name) AS DistinctValues FROM [CData].[GoogleSpanner].Customer WHERE CustomerId = '12345'
AVG
Returns the average of the column values.
SELECT AVG(AnnualRevenue) FROM [CData].[GoogleSpanner].Customer WHERE CustomerId = '12345'
MIN
Returns the minimum column value.
SELECT MIN(AnnualRevenue) FROM [CData].[GoogleSpanner].Customer WHERE CustomerId = '12345'
MAX
Returns the maximum column value.
SELECT MAX(AnnualRevenue) FROM [CData].[GoogleSpanner].Customer WHERE CustomerId = '12345'
SUM
Returns the total sum of the column values.
SELECT SUM(AnnualRevenue) FROM [CData].[GoogleSpanner].Customer WHERE CustomerId = '12345'