Aggregate Functions

Another important category of functions includes those known as aggregate functions. These include Sum(), Count(), Min(), Max(), and Avg(). These all work in similar, quite intuitive ways. Each operates on a set of inputs (numeric, except for the Count() function) and produce a numeric output. The name of the function implies the operation each performs.

Sum() adds a set of numbers, Min() and Max() return the smallest and largest items of a set, Avg() returns the arithmetic mean of the numbers, and Count() returns the number of non-null values in the set.

The inputs for an aggregate function can come from any one of three sources:

Note

When using the Count() function to count related records, it usually doesn't matter what field you count, as long as it's not empty. The count will not include records in which the specified field is blank. Typically, you should count either the related primary key or the related foreign key because these by definition should contain data.

Категории