613-518-1166 info@zimdatabases.com

ZIM Language Reference

SORTED BY

< All Topics

SORTED BY

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

Syntax

SORTED BY «expression [ASCENDING|DESCENDING]»

Parameters

expression

An expression that identifies a field to be used as a sort key. Complex expressions must be enclosed in parentheses.

ASCENDING or DESCENDING

Specifies 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?
0 out Of 5 Stars
5 Stars 0%
4 Stars 0%
3 Stars 0%
2 Stars 0%
1 Stars 0%
How can we improve this article?
Table of Contents