Database Reference
In-Depth Information
47
Groups records
using sales
rep numbers
Calculates the
average balance
for each group
FIGURE 2-21
Query to group records
The query results appear in Figure 2-22.
Average balance
for all customers
of each sales rep
Records grouped
by sales rep number
FIGURE 2-22
Query results
SORTING
In most queries, the order in which records appear doesn
t matter. In other queries, however, the order in
which records appear can be very important. You might want to see customers listed alphabetically by cus-
tomer name or listed by rep number. Further, you might want to see customer records listed alphabetically
by customer name and grouped by sales rep number.
To list the records in query results in a particular way, you need to sort the records. The field on which
records are sorted is called the sort key; you can sort records using more than one field when necessary.
When you are sorting records by more than one field (such as sorting by rep number and then by customer
name), the first sort field (RepNum) is called the major sort key (also called the primary sort key) and the
second sort field (CustomerName) is called the minor sort key (also called the secondary sort key).
To sort in Access, specify the sort order in the Sort row of the design grid for the sort key field.
'
EXAMPLE 11
List the customer number, name, balance, and rep number for each customer. Sort the output alphabetically
by customer name.
To sort the records alphabetically using the CustomerName field, select the Ascending sort order in the
Sort row for the CustomerName column, as shown in Figure 2-23. (To sort the records in reverse alphabeti-
cal order, select the Descending sort order.)
Search WWH ::




Custom Search