Quick References
ADO
ASP
CSS2
HTML
JavaScript
Jet SQL
VBScript
WML
WMLScript
WSH
XHTML
XML DOM
XSLT
Features
Knowledge Base
Tutorials
Partners
ZVON.ORG
XML
Planet Source Code
VisualBuilder
Web Design
Your HTML Source
XML/XSLT Forums
ASPAlliance
Scripts
Programmers Heaven
Tek-Tips Forums
Developer Fusion
Code Project
All Clauses
SELECT Statement
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 1999-2005 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information