GCFLearnFree.org

I love your videos. Everything is so precise and to the point.”

Online Learner

GCFGlobal.org
Creating Opportunities For A Better Life.®
  • All Topics
  • Access 2007
  • Using Queries to Make Data Meaningful - Part 2

Access 2007

Single page view print copy

Using Queries to Make Data Meaningful - Part 2

Using Count and Group By in a query

When you use the Totals command in a query, Access will automatically group every field by the values in each field. This means that it will look for repeating values and group the like values together so they appear as one record rather than as many records. This is called the Group By function.

Take our bookstore database for 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:

Ordered BooksQuery for Ordered Books

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.

To use the Count and Group By options in a query

To include the Group By and the Count functions in a query:

  • Click on Totals in the Show/Hide group on the Ribbon.

    Totals CommandTotals Command

    The Total row will instantly appear in the bottom portion of the query design screen.

    Totals CommandTotal Row in Query Design


  • Click in the Totals row for the field you wish to count. We want to count the number of times the same Book ID appears in the Orders table.
  • From the list of optional Totals functions, select Count.

    Totals OptionsTotal Options in Query Design


  • Click Run! to see your results. Notice that each title, author, price, and category is now listed only one time for each book, with an extra column that indicates the number of times the Book ID appeared in the Orders table.

    Count QueryCount and Group By Functions in Query Results


previous next
previous 1 2 3 4 5 next
Terms Of Use

©1998-2014 Goodwill Community Foundation, Inc. All rights reserved.