You already know how to plan and run a basic query. This lesson will show you how to run a query that includes a Totals function to group and count the records in the results. It will also deal with ways to further sort and filter via your query design to further refine your results.
Download the example to work along with the video.
Sometimes you may want to see your query results grouped or counted in some way. Access 2007 offers several options to make these functions possible. Perhaps the easiest of these is the Totals command, whose optional functions are similar to the functions used in Microsoft Excel. These functions include:
One of the most useful totals functions to use in queries is the Count function.
When you use the Totals command in a query, Access will automatically group every field by the values in each field. This means it will look for repeating values and group like values together so they appear as one record rather than as many records. This is called the Group By function.
Let's use our bookstore database as an example. If we run a query to see the information for every book that has been ordered, we'd get a list that looks like this:
Notice that we get a record back for every order of each book that has been ordered.
In our bookstore example query, we want to see these titles grouped together so we see each ordered title only one time. To do this, we use the Count and Group By options.
Once you have the results looking how you want them, you can sort and filter them to further narrow your results. This can be done using the methods of sorting and filtering covered in earlier lessons, or by applying a sort and filter in the query design itself.
If you haven't already done so, save the sample Ready2Read database to your computer.
- Create a query that uses the Count and Group By options.
- Modify a query design to include a sort .
- Run the query, and view your results.
- Save the query.
- Modify a query design to include filter c riteria .
- Run the query, and view your results.
- Save the query.