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;


Tinggalkan Balasan

Alamat email Anda tidak akan dipublikasikan. Ruas yang wajib ditandai *