Aggregate Functions

Examples of Aggregate Functions

Below are several examples of SQL aggregate functions.

COUNT

Returns the number of rows matching the query criteria.

SELECT COUNT(*) FROM "CData"."Sample".Products WHERE Industry = 'Floppy Disks'

AVG

Returns the average of the column values.

SELECT  AVG(AnnualRevenue) FROM "CData"."Sample".Products WHERE Industry = 'Floppy Disks'

MIN

Returns the minimum column value.

SELECT MIN(AnnualRevenue) FROM "CData"."Sample".Products WHERE Industry = 'Floppy Disks'

MAX

Returns the maximum column value.

SELECT  MAX(AnnualRevenue) FROM "CData"."Sample".Products WHERE Industry = 'Floppy Disks'

SUM

Returns the total sum of the column values.

SELECT SUM(AnnualRevenue) FROM "CData"."Sample".Products WHERE Industry = 'Floppy Disks'