Reporting : Native reporting system : Reporting system command language : ORDERBY command
  
ORDERBY command
Description
The ORDERBY command controls the sequence of the output of a report. The Reporting System uses the first field name listed as its major sort field; the second field as a minor sort field; and so forth. The KEYLENGTH subcommand is used to specify the length of a field used in the ORDERBY command
Note The ORDERBY command, and KEYLENGTH subcommand can only be placed in a report in text mode. However, you can use the Sort buttons in the Edit <Report Name> dialog (see Editing and adding the report sort criteria) to reorder the report fields.
ORDERBY command structure
The structure of the ORDERBY command is:
ORDERBY field-identifier-1 KEYLENGTH numeric,
field-identifier-2 KEYLENGTH numeric
C:\Users\wjn\AppData\Local\Temp\506626\html\bitmaps\ordercmd.gif
Rules for using the ORDERBY command
1 The field-identifiers in the ORDERBY command must be separated by a comma. When the field-identifier is used with the KEYLENGTH subcommand, use a comma after the KEYLENGTH number. Use white space to the right of any comma placed in the statement.
2 The sort sequence can only be specified for a tabular report; matrix reports are not sorted. The sort sequence is always ascending.
3 A memo type field, such as description, cannot be sorted. Also, a field that is defined as “text” in the Master Properties Configuration Set but “memo” in a FIELD command cannot be sorted.
4 The 100-character limitation can be a problem if multi-level sorts are specified. For example, a name field sort alone uses 80 characters. A sort can be equally effective if fewer than the full number of characters in a field are used for sorting. For example, a user might know that sorting on the first 20 characters in the name field is sufficient.
Examples – ORDERBY command
These are some examples of how you may use the ORDERBY command.
Example 1 – ORDERBY command
The following ORDERBY command sorts the output by Name within Type. Type is the major sort field, Name is the minor field:
ORDERBY Type, Name
The total of all sort fields in a report definition is limited to 100 characters. This limitation includes all sort fields in all ORDERBY command lines in the report. (This limitation is a dBASE constraint.)
Example 2 – ORDERBY command
Use the KEYLENGTH specification to constrain the sort to a specified number of characters. The following example limits sorting to the first 20 characters of the Name field:
ORDERBY Type, Name KEYLENGTH 20
Example 3 – ORDERBY command
The following statement limits sorting on Type to 2 characters, and Name to 15 characters:
ORDERBY Type KEYLENGTH 2, Name KEYLENGTH 15
Parent topic
Reporting system command language