Use the GROUP BY clause to write SQL queries that group and aggregate data
Source: Addison Wesley Professional
Introduction to SQL, long the definitive SQL tutorial for database professionals, has been updated to reflect the latest SQL standards and newest versions of today's leading RDBMSs: Oracle, Microsoft SQL Server, DB2, and MySQL. Throughout, case study examples and hands-on exercises illuminate key SQL concepts, techniques, and statements. In this sample chapter, focus on mastering the SELECT statement (the GROUP BY clause). The GROUP BY clause groups rows on the basis of similarities between them and is used frequently to formulate questions based on the word "per." Learn that by adding aggregation functions, such as COUNT and SUM, to a select block with the use of a GROUP BY clause, data can be aggregated; that is, one can write queries for data not as individual values but as summations, averages, frequencies and subtotals.
Title: Introduction to SQL: Mastering the Relational Database Language, 4th Edition
Published: September 2006
Author: Rick F. van der Lans
Chapter: Chapter 10: SELECT Statement: The GROUP BY Clause
Published by Addison Wesley Professional