SORTED BY

SORTED BY

Welcome to our Knowledge Base

Documentation | Blog | Demos | Support

< All Topics
Print

SORTED BY

SORTED BY

Sorts the members of the set produced by the main command.

Syntax

SORTED BY «expression [ASCENDING|DESCENDING]»

Parameters

expressionAn expression that identifies a field to be used as a sort key. Complex expressions must be enclosed in parentheses.
ASCENDING or DESCENDINGSpecifies how the sort on the associated key is to be performed.
ASCENDING (default)
Sorts in “alphabetical order” (A-Z, 0-9).
DESCENDING
Sorts in “reverse alphabetical order” (Z-A, 9-0).

Comments

The sorting clause determines the order in which the selected records are to appear in the set. The fields to be used as sort keys (identified by each expression) must be part of the set produced by the main command.

If you omit the sorting clause, the software determines the order of the records.

Note: Existing result sets can also be sorted after selection – with the SORT command.

Example

list all Employees sorted by Department descending FirstName LastName

The preceding command lists all Employees by department (in descending order) and, within department, by first and last names (in ascending order).

report from Invoices
sorted by {$month(InvoiceDate)-5
where $month(InvoiceDate) >= 6,
$month(InvoiceDate)+7}
:
endreport

The preceding program fragment reports invoices in order by fiscal month, assuming that the fiscal year begins in June.

See Also

SORT

Was this article helpful?
5 out of 5 stars

1 rating

5 Stars 100%
4 Stars 0%
3 Stars 0%
2 Stars 0%
1 Stars 0%
5
How can we improve this article?
Please submit the reason for your vote so that we can improve the article.

Leave a Reply

Your email address will not be published. Required fields are marked *

en_CAEnglish