SQL ORDER BY Keyword
SQL ORDER BY Keyword
The ORDER BY keyword is used to sort the result-set.
The ORDER BY Keyword
The 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 Example
The "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:
ORDER BY DESC Example
Now 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:
Comments
Post a Comment