What is SQL ORDER BY?
The SQL ORDER BY clause is the part of the SELECT statement that controls the sequence of information returned.
The SQL ORDER BY clause is really a sort feature that enables the output to be sorted by one or more columns.
Why Use SQL ORDER BY?
Use the SQL ORDER BY clause whenever it is desirable to control the sequence output through a SELECT clause. It might be used to alphabetize a report or to print the most import items at the beginning of a report.
How To Use SQL ORDER BY
SQL ORDER BY is used as follows.
SQL ORDER BY Syntax
Multiple columns can be included in the ORDER BY clause. The direction of the sort is controlled by:
SQL ORDER BY Example
The following example displays rows from the branch in region_nbr and branch_nbr ascending sequence.
Here are the contents of the table:
This SQL Statement with ORDER BY is executed:
Here is the result.