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