When you create a Query, the records are displayed in an arbitrary order. This means that the underlying database gets to choose the sequence in which they appear – which may simply be the order they were entered, but there is no guarantee, nor can it be assumed that the order will remain the same.
- If your Query will be used to display a single record at a time, then this does not matter, and specifying a sort order will simply serve to slow the system unnecessarily.
- If your Query will be showing more than one record you will want to specify a sort order.
To specify a sort order:
Add the Fields which will be used in the sequencing to your Query.
Then, set the Sort to the order you want (Ascending, Descending, or Random).
You may want to sort by several fields. This means that if two records have the same value for the first field you are sorting on, then the second field is used as a 'tie-breaker' to sort them. A common example of this is where you are sorting by Surname and Firstname.
To sort by several fields:
Add them to the Query, and specify the sort order for each. The system will then work left-to-right across the query fields.
If you are using a Grid View, and the column order you want to display the fields in conflicts with the order you need them in to perform your sorting, you can add the same field in two positions, and uncheck the Show checkbox for one of them. See 'Showing and Hiding fields' for an example.
There are four possible sort orders.
'(none)' means the database will choose an unpredictable arbitrary order.
Ascending means A-Z, 0-9, and for dates, earlier to later
Descending means 9-0, Z-A, and for dates, later to earlier
Random means each display will be guaranteed random, ie the probability of a given record being chosen is equally likely, however by definition this means you may see the same record in subsequent views. Note that Random guarantees randomness, whereas '(none)' guarantees nothing.