J. Notes for Users of QUEL : Retrieve (QUEL) : The Sort and Order Clauses
 
Share this page                  
The Sort and Order Clauses
The sort clause removes duplicate rows from the retrieval and sorts the remaining rows on the basis of the specified simple fields of the current form (or columns of the table field).
The order clause is identical to the sort clause, except that it does not remove duplicate rows.
The full syntax for the sort and order clauses is as follows:
sort [by] fieldname[:sortorder]
  {, fieldname[:sortorder]} |
order [by] fieldname[:sortorder]
  {, fieldname[:sortorder]}
If more than one fieldname is specified in the sort or order clause, rows are sorted on the basis of the first fieldname, second fieldname, and so on, and within values of that field, on the basis of the specified sortorder. Specify a sortorder of asc or ascending (the default), or desc or descending.
The sort and order clauses require that you specify field names from the form, not column names from the database table. Consider the following examples:
empform := retrieve (employee.ename, 
  employee.dept)
  sort by ename;
and
newform := retrieve (person=employee.ename,
  employee.dept)
  sort by person;
Both are correct. However, in the latter query it is incorrect to sort by Ename, because Ename is a column in the table and not a field in the form.