FairCom Corporation


2.28 ORDER BY CLAUSE


Description

The ORDER BY clause specifies the sorting of rows retrieved by the SELECT statement. SQL does not guarantee the sort order of rows unless the SELECT statement includes an ORDER BY clause.

Syntax

ORDER BY { expr | posn } [ ASC | DESC ]
[ , { expr | posn } [ASC | DESC] ,... ]

Notes

-- Get a merged list of customers and suppliers
-- sorted by their name.
(SELECT name, street, state, zip
FROM customer
UNION
SELECT name, street, state, zip
FROM supplier)
ORDER BY 1 ;

Example

SELECT name, street, city, state, zip
FROM customer
ORDER BY name ;

FairCom Corporation
www.faircom.com