An aggregation function returns a single calculated value from a set of related values. Averages are one type of data aggregation; they calculate a single averaged value from an input of multiple source values. ADO.NET includes seven aggregation functions for use in expression columns and other DataTable features.
■■ Sum Calculates the total of a set of column values. The column being summed must be numeric, either integral or decimal.
■■ Avg Returns the average for a set of numbers in a column. This function also requires a numeric column.
■■ Min Indicates the minimum value found within a set of column values. Numbers, strings, dates, and other types of data that can be placed in order are all valid for the target column.
■■ Max Like Min, but returns the largest value from the available column values. As with the Min function, most column types will work.
■■ Count Simply counts the number of rows included in the aggregation. You can pass any type of column to this function. As long as a row includes a non-NULL value in that column, it will be counted as 1.
■■ StDev Determines the statistical standard deviation for a set of values, a common measure of variability within such a set. The indicated column must be numeric.
■■ Var Calculates the statistical variance for a set of numbers, another measurement related to the standard deviation. Only numeric columns are supported.
In ADO.NET, aggregates always summarize a single DataTable column. Each aggregate function considers only non-NULL column values. Rows that contain NULL values in the specified column are excluded from the aggregation