CLAUSE: ORDER BY
SELECT fieldlist FROM table WHERE selectcriteria
[ORDER BY field1 [ASC | DESC ][, field2 [ASC | DESC ]][, ...]]]
The ORDER BY clause can be used to dictate
the order of the records returned (i.e., how they are sorted). The following example returns
records listed primarily in order of tune type (jigs then reels),
and then for each type the relevant names are also listed in
alphabetical order:
SELECT TuneType AS Type, Name FROM Tunes
WHERE TuneType = 'jig' OR TuneType = 'reel'
ORDER BY TuneType, Name;
You can specify descending order (the default is ascending order)
by adding the reserved word DESC after the field name.
The next example returns a list of all items in ascending
alphabetical order along with their prices in descending numerical
order:
SELECT Item, Unitprice AS Price
FROM Products
ORDER BY Item, UnitPrice DESC;
Copyright 2000 by Infinite Software Solutions, Inc.
Trademark Information
|