MySQL Data Aggregation Functions

Revision as of 18:40, 24 October 2007 by Neil (Talk | contribs) (New page: Sometimes when working with the data stored in a MySQL database table, we are interested not in the data itself, but in statistics about that data. For example, we may not be concerned abo...)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Revision as of 18:40, 24 October 2007 by Neil (Talk | contribs) (New page: Sometimes when working with the data stored in a MySQL database table, we are interested not in the data itself, but in statistics about that data. For example, we may not be concerned abo...)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Sometimes when working with the data stored in a MySQL database table, we are interested not in the data itself, but in statistics about that data. For example, we may not be concerned about the specific content in each row, we may want to know how many rows are in a table. Alternatively, we may need to find the average of all the values in a particular table column. Information of this type can be obtained using a collection of built-in MySQL aggregate functions and these functions are the topic of this chapter.

The MySQL Aggregate Functions

MySQL supports the following aggregate functions:


FunctionDescription
AVG()Returns the average of the values in the selected column
COUNT()Returns the number of rows returned for a selection
MAX()Returns the maximum value for a column
MIN()Returns the minimum value of a column
SUM()Returns the sum of the values in a specified column