What is SQL (6)
After selecting the data you are looking for, you may want to sort them. ORDER BY
keyword is used to sort the result-set. The syntax looks like this:
SELECT column_name...
FROM table_name
ORDER BY column_name ASC|DESC, column_name ASC|DESC;
The default is to sort the records in ascending order. Therefore, if you do not necessarily need to explicit write down ‘ASC’. To sort the records in a descending order, use ‘DESC’ after ORDER BY
. You can use multiple columns to sort the results.
‘US City’:
Quick Example:
SELECT City
FROM US City
ORDER BY State, City DESC;