Microsoft Office Tutorials and References
In Depth Information
In some queries, the order in which the records appear really does not matter. All you
need to be concerned about are the records that appear in the results. It does not matter
which one is ﬁ rst or which one is last.
In other queries, however, the order can be very important. You may want to see the
cities in which clients are located and would like them arranged alphabetically. Perhaps
you want to see the clients listed by recruiter number. Further, within all the clients of any
given recruiter, you might want them to be listed by amount paid from largest amount to
To order the records in the answer to a query in a particular way, you sort the
records. The ﬁ eld or ﬁ elds on which the records are sorted is called the sort key . If you
are sorting on more than one ﬁ eld (such as sorting by amount paid within recruiter
number), the more important ﬁ eld (Recruiter Number) is called the major key (also called
the primary sort key ) and the less important ﬁ eld (Amount Paid) is called the minor key
(also called the secondary sort key ).
To sort in Microsoft Access, specify the sort order in the Sort row of the design grid
below the ﬁ eld that is the sort key. If you specify more than one sort key, the sort key on
the left will be the major sort key and the one on the right will be the minor key.
The following are guidelines related to sorting in queries.
Determine whether special order is required.
1. Determine whether sorting is required . Examine the query or request to see if it contains
words such as “order” or “sort” that would imply that the order of the query results is
important. If so, you need to sort the query.
2. Determine the sort key(s) . If sorting is required, identify the ﬁ eld or ﬁ elds on which the
results are to be sorted. Look for words such as “ordered by“ or “sort the results by,”
both of which would indicate that the speciﬁ ed ﬁ eld is a sort key.
3. If using two sort keys, determine major and minor key . If you are using two sort keys,
determine which one is more important. That will be the major key. Look for words such
as “sort by amount paid within recruiter number,” which imply that the overall order is
by recruiter number. Thus, the Recruiter Number ﬁ eld would be the major sort key and
the Amount Paid ﬁ eld would be the minor sort key.
4. Determine sort order . Words such as “increasing,” “ascending,” or “low-to-high” imply
Ascending order. Words such as “decreasing,” “descending,” or “high-to-low” imply
Descending order. Sorting in alphabetical order implies Ascending order. If there are no
words to imply a particular order, you would typically use Ascending.
5. Determine restrictions . Examine the query or request to see if there are any special
restrictions. One common restriction is to exclude duplicates. Another common restriction
is to list only a certain number of records, for example to list only the ﬁ rst ﬁ ve records.