ORDER BY clause

The ORDER BY clause indicates how the records are to be sorted. If your SELECT statement doesn’t include an ORDER BY clause, the records may be returned in any order.

The format is:

Copy
ORDER BY {sort_expression [DESC | ASC]}, ...

sort_expression can be the field name or the positional number of the column expression to use. The default is to perform an ascending (ASC) sort.

Examples

Sort by last_name then by first_name.

Copy
SELECT emp_id, last_name, first_name FROM emp ORDER BY last_name, first_name

The second example uses the positional numbers 2 and 3 to get the same ordering as the prior example that specified last_name and first_name explicitly.

Copy
SELECT emp_id, last_name, first_name FROM emp ORDER BY 2,3

Note  FileMaker Server uses a Unicode binary sort order, which is different from language sorting in FileMaker Pro or with the default language-neutral sort order.