Use the GROUP BY clause to aggregate data in MySQL
Source: Addison Wesley Professional
SQL is a compact and powerful language for working with databases, and MySQL offers a SQL dialect with particular power. SQL for MySQL Developers: A Comprehensive Tutorial and Reference helps you master this version of SQL and take advantage of its full potential by using case study examples and hands-on exercises to illuminate key concepts, techniques, and statements. In this sample chapter, focus on mastering the GROUP BY clause, which is frequently used to formulate questions based on the word per. By adding aggregation functions such as COUNT and SUM to a select block with the use of a GROUP BY clause, you can aggregate data and ask for summaries, averages, frequencies, and subtotals instead of individual values.
Title: SQL for MySQL Developers: A Comprehensive Tutorial and Reference
Published: April 2007
Author: Rick F. van der Lans
Chapter: Chapter 10: The Group By Clause
Published by Addison Wesley Professional