ORDER BY FORMULA

4D - Documentation   Français   English   German   4th Dimension 2004, Command Theme List   4th Dimension 2004, Command Alphabetical List   4th Dimension 2004, Constant Theme List   Back   Previous   Next

version 3


ORDER BY FORMULA (table{; expression{; > or <}}{; expression2; > or <2; ...; expressionN; > or <N})

ParameterTypeDescription
tableTableTable for which to order selected records
expressionExpression on which to set the order for each level
(can be of type Alphanumeric, Real, Integer,
Long Integer, Date, Time or Boolean)
> or <Ordering direction for each level:
> to order in ascending order, or
< to order in descending order

Description

ORDER BY FORMULA sorts (reorders) the records of the current selection of table for the current process. After the sort has been completed, the new first record of the selection becomes the current record.

Note that you must specify table. You cannot use a default table.

You can sort the selection on one level or on several levels. For each sort level, you specify a expression in expression and the sorting order in > or <. If you pass the "greater than" symbol (>), the order is ascending. If you pass the "less than" symbol (<), the order is descending. If you do not specify the sorting order, ascending order is the default.

The parameter expression can be of type Alphanumeric, Real, Integer, Long Integer, Date, Time or Boolean.

No matter what way a sort has been defined, if the actual sort operation is going to take some time to be performed, 4th Dimension automatically displays a message containing a progress thermometer. These messages can be turned on and off by using the commands MESSAGES ON and MESSAGES OFF. If the progress thermometer is displayed, the user can click the Stop button to interrupt the sort. If the sort is completed, OK is set to 1. Otherwise, if the sort is interrupted, OK is set to 0 (zero).

4D Server: Since expression cannot be interpreted by 4D Server, each record is sent to the local workstation; the order formula is evaluated on the workstation. This will make the order inefficient. Use the ORDER BY command whenever possible.

Unlike ORDER BY, ORDER BY FORMULA always performs a sequential sort.

Example

This example orders the records of the [People] table in descending order, based on the length of each person's last name. The record for the person with the longest last name will be first in the current selection:

   ORDER BY FORMULA ([People]; Length([People]Last Name);<)

See Also

ORDER BY.


4D - Documentation   Français   English   German   4th Dimension 2004, Command Theme List   4th Dimension 2004, Command Alphabetical List   4th Dimension 2004, Constant Theme List   Back   Previous   Next