ORDERING OF THE QUERY RESULT

The ORDER BY clause is used to force the query result to be sorted based on one or more column values.  You can select either ascending or descending sort for each named column.

Example 1

List the names and IDs of all faculty members arranged in alphabetical order.
SELECT FACID, FACNAME FROM FACULTY ORDER BY FACNAME;

FACID FACNAME
F101 Adams
F110 Byrne
F221 Smith
F202 Smith
F105 Tanaka

Example 2

List names and IDs of faculty members.  The primary sort is the name and the secondary sort is by descending ID (for seniority purposes).
SELECT FACID, FACNAME FROM FACULTY ORDER BY FACNAME, FACID DESC;

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>