The ORDER BY clause to sort the rows
The results from a query are not arranged in any particular order. For example, Query result and Query result appear to be in random order.
You can add an ORDER BY clause to your SELECT statement to direct the system to sort the data in a specific order. The ORDER BY clause is a list of column names from any remote or local table or view. Any expressions that are allowed in the projection list are allowed in the ORDER BY list. If a column used in the ORDER BY list has a Select trigger on it, the trigger will not be activated.
The following query returns every row from the manu_code, manu_name,
and lead_time columns in the manufact table, sorted
according to lead_time.
For ,
you do not need to include the columns that you want to use in the
ORDER BY clause in the projection list. That is, you can sort the
data according to a column that is not retrieved in the projection
list. The following query returns every row from the manu_code and manu_name columns
in the manufact table, sorted according to lead_time.
The lead_time column is in the ORDER BY clause although it
is not included in the projection list.