Sams Teach Yourself SQL in 24 Hours, Third Edition By Ronald R. Plew, Ryan K. Stephens
Table of Contents
Hour 10. Sorting and Grouping Data
You have learned how to group the results of a query using the GROUP BY clause. The GROUP BY clause is primarily used with aggregate SQL functions like SUM, AVG, MAX, MIN, and COUNT. The nature of GROUP BY is like that of ORDER BY in that both sort query results. The GROUP BY clause must sort data to group results logically, but can also be used exclusively to sort data, although an ORDER BY is much simpler for this purpose.
The HAVING clause, an extension to the GROUP BY clause, is used to place conditions on the established groups of a query. The WHERE clause is used to place conditions on a query's SELECT clause. During the next hour, you learn a new arsenal of functions that allow you to further manipulate query results.