Database Reference
In-Depth Information
12
Summarizing Data
In this chapter, you learn what the SQL aggregate functions are and how to use
them to summarize table data.
Using Aggregate Functions
It is often necessary to summarize data without actually retrieving it all, and
MariaDB provides special functions for this purpose. Using these functions,
MariaDB queries are often used to retrieve data for analysis and reporting pur-
poses. Examples of this type of retrieval are
Determining the number of rows in a table (or the number of rows
that meet some condition or contain a specific value)
Obtaining the sum of a group of rows in a table
Finding the highest, lowest, and average values in a table column
(either for all rows or for specific rows)
In each of these examples, you want a summary of the data in a table, not the
actual data itself. Therefore, returning the actual table data would be a waste of
time and processing resources (not to mention bandwidth). To repeat, all you
really want is the summary information.
To facilitate this type of retrieval, MariaDB features a set of aggregate func-
tions, some of which are listed in Table 12.1. These functions enable you to
perform all the types of retrieval just enumerated.
Note
Aggregate functions Functions that operate on a set of rows to calculate and return a
single value.
 
 
 
Search WWH ::




Custom Search