Use Aggregate Functions

You will rarely use the Group By clause without also employing one of the SQL aggregate functions. The five SQL aggregate functions are Count(), Sum(), Avg(), Min(), and Max(). Their names give a good indication of what they do. For example, Count() tallies the number of records, Sum() calculates the total of a mathematical expression of fields, and Avg() calculates the average of a mathematical expression of fields. Details on how each of these aggregate functions works are presented in the following three sections.

The Count() Function

The Count() function counts the number of records for each group. In this case, there are two groups, one each for business and individual clients. The question you are attempting ...

Get Absolute Beginner’s Guide to Databases 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.