SQL Basic
SQL Advanced
SQL Functions
| SQL Order By |
|
The ORDER BY keyword is used to sort the result-set. The ORDER BY KeywordThe ORDER BY keyword is used to sort the result-set by a specified column. The ORDER BY keyword sort the records in ascending order by default. If you want to sort the records in a descending order, you can use the DESC keyword. SQL ORDER BY Syntax
ORDER BY ExampleThe "Persons" table:
Now we want to select all the persons from the table above, however, we want to sort the persons by their last name. We use the following SELECT statement:
The result-set will look like this:
ORDER BY DESC ExampleNow we want to select all the persons from the table above, however, we want to sort the persons descending by their last name. We use the following SELECT statement:
The result-set will look like this:
|
SQL Order By