SQL Quick Reference
Looking for a SQL quick reference? Our free online SQL tutorial provides
examples of SQL commands and SQL syntax. Bookmark our site and use
our SQL tutorial as a SQL quick reference.
Displaying Rows in Descending Order
If you would like to see fields displayed in descending order, follow
the field name with "desc" in the Order By clause.
Syntax:
Select */fieldname ...
from tablename
order by fieldname <desc> ...
Explanation:
- By default, the Order By clause tells SQL you want the field displayed
in ascending order.
- Typing "desc" after the field name in the
Order By clause tells SQL you want the data in the field displayed
in descending
order (Z to A, 100 to 1).
Example:
Retrieve the city, vendor ID, and name from the TrnVendor table.
Order your data by city in descending order:
- In the SQL text box, type:
Select City, VendId, Name
from TrnVendor
order by City desc;
- Execute the SQL statement.
Results
| City |
VendId |
Name |
| Youngstown |
TV018 |
Computer Bytes |
| Warren |
TV002 |
The Games All Here |
| Toledo |
TV027 |
Narrow Nest |
| Toledo |
TV014 |
Counter Productive |
| Toledo |
TV009 |
Hit the Deck |
| Toledo |
TV001 |
Wet Off Towels |
| Park Ridge |
TV015 |
No Waste Disposal |
| Park Ridge |
TV006 |
Mosquito No Bite |
| Orlando |
TV025 |
Against the Tide |
| Orlando |
TV010 |
The Soda Factory |
| New York |
TV012 |
Paper People |
| Monroe |
TV013 |
Softer Software |
| Monroe |
TV008 |
Big Tree Landscaping |
| Mercer |
TV011 |
The Freelance |
| Mercer |
TV004 |
Bed Room Furniture, Inc. |
| Houston |
TV022 |
Legal Lookup |
| Freeport |
TV024 |
Enterprise Transport |
| Freeport |
TV023 |
World Wide Learning U |
| Freeport |
TV017 |
Food Four |
| Detroit |
TV007 |
Spot Out |
| Detroit |
TV005 |
Ray Block |
| Dallas |
TV026 |
Clampett Oil |
| Dallas |
TV021 |
Cooperative Operatives |
| Chicago |
TV030 |
Make Shift Tilts |
| Chicago |
TV029 |
Paltry Play |
| Chicago |
TV028 |
Distant Horizons |
| Chicago |
TV016 |
Music Maker |
| Chicago |
TV003 |
BedMakers Linen |
| Burlington |
TV020 |
BayCon Group |
| Bayshore |
TV019 |
Bayshore Consulting |
|
|
|
|