Database Toolbox | ![]() ![]() |
Presenting Results in Specified Order
By default, the order of the rows in the query results depends on their order in the database, which is effectively random. Use the Order by field in Advanced query options to specify the order in which results appear. This example uses basic_where.qry
, created and saved in Retrieving Information That Meets Specified Criteria. This example sorts the results of basic_where.qry
, so that January is the primary sort field, February the secondary, and March the last. Results for January and February are ascending, and for March, are descending.
basic_where.qry
. For instructions, see Using a Saved Query.January
.
1
.
February
.
2
.
March
.
3
.
The ORDER BY Clauses dialog box closes. The SQL statement in the Visual Query Builder reflects the order by clause you specified.
B
.B
in the Command Window. Compare these to the unordered query results, shown as A
.For B
, results are first sorted by January sales, in ascending order, from 1200 for 400455 to 5000 for 400345.
For items 400999, 400314, and 400876, January sales were equal at 3000. Therefore, the second sort key applies, February sales in ascending order, which were 1500, 2400, and 2400 respectively.
For 400314 and 400876, February sales were both 2400, so the third sort key applies, March sales in descending order, which were 1800 and 1500 respectively.
![]() | Grouping Criteria | Creating Subqueries for Values from Multiple Tables | ![]() |