Chapter 10. Aggregate Functions and Clauses
It is not overstating things to say that MySQL queries can return a significant amount of data. As we have seen with the SELECT
statement, using clauses such as WHERE
reduces the number of hits that MySQL returns. Similarly, one can reduce the amount of data returned by specifying the columns to be returned. Such features save us from having to write our own algorithms to weed through the data. However, even after narrowing the data, we sometimes still need to perform calculations with the data for purposes such as tallying a sum, averaging out results, or finding the range of a dataset. MySQL saves us this trouble as well, by providing functions that return the answers to our questions without bothering us with the data. These summative operations are called aggregate functions.
In this chapter, we will see how:
MySQL saves us time and effort by pre-processing data
To perform several calculations using MySQL's optimized algorithms
To group and order...