Summary

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.

Get Sams Teach Yourself SQL in 24 Hours, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.