Database Reference
In-Depth Information
48
Ascending sort
order specified for the
CustomerName field
Sort row
FIGURE 2-23
Query to sort records
The query results appear in Figure 2-24. Notice that the customer names appear in alphabetical order.
Records sorted
alphabetically by
customer name
FIGURE 2-24
Query results
Sorting on Multiple Keys
You can specify more than one sort key in a query; in this case, the sort key on the left in the design grid will
be the major (primary) sort key and the sort key on the right will be the minor (secondary) sort key. Example
12 illustrates the process.
EXAMPLE 12
List the customer number, name, balance, and rep number for each customer. Sort the output by sales rep
number. Within the customers of each sales rep, sort the output by customer name.
To sort records by sales rep number and then by customer name, RepNum is the major sort key and
CustomerName is the minor sort key. You might be tempted to select the sort orders for these fields in the
design grid, but your results would not be sorted correctly. Figure 2-25 shows an incorrect query design.
Search WWH ::




Custom Search