order by clause in SQL

When you query data from a table, the SELECT statement returns rows in an unspecified order. To sort the rows of the result set, you use the ORDER BY clause in the SELECT statement.
The ORDER BY clause allows you to sort rows returned by a SELECT clause in ascending or descending order based on a sort expression.
The following illustrates the syntax of the ORDER BY clause:
```
SELECT
	select_list
FROM
	table_name
ORDER BY
	sort_expression1 [ASC | DESC],
        ...
	sort_expressionN [ASC | DESC];
```
In this syntax:
*    First, specify a sort expression, which can be a column or an expression, that you want to sort after the ORDER BY keywords. If you want to sort the result set based on multiple columns or expressions, you need to place a comma (,) between two columns or expressions to separate them.
*    Second, you use the ASC option to sort rows in ascending order and the DESC option to sort rows in descending order. If you omit the ASC or DESC option, the ORDER BY uses ASC by default.

SQL evaluates the clauses in the SELECT statement in the following order: FROM, SELECT, and ORDER BY.
Due to the order of evaluation, if you have a column alias in the SELECT clause, you can use it in the ORDER BY clause.
```
SELECT
	first_name,
	last_name
FROM
	customer
ORDER BY
	first_name ASC;
```