When ordering your data, you can have multiple sort levels. For example, you can order your data by city and then by name within the city.
Syntax:
Select fieldname, fieldname, fieldname
from tablename
order by fieldname <desc>, fieldname <desc>, fieldname <desc>
from tablename
order by fieldname <desc>, fieldname <desc>, fieldname <desc>
Explanation:
- By default, the Order By clause orders the specified fields in ascending order.
- Typing "desc" after a field name in the Order By clause tells SQL you want the data in the specified field displayed in descending order (Z to A, 100 to 1).
- The first field name specified is the primary sort order, the second field name specified is the secondary sort order, and so on ...
- In the SQL text box, type:
Select City, Name, VendId
from TrnVendor
order by City, Name;
from TrnVendor
order by City, Name;
- Execute the SQL statement.
City | Name | VendId |
Bayshore | Bayshore Consulting | TV019 |
Burlington | BayCon Group | TV020 |
Chicago | BedMakers Linen | TV003 |
Chicago | Distant Horizons | TV028 |
Chicago | Make Shift Tilts | TV030 |
Chicago | Music Maker | TV016 |
Chicago | Paltry Play | TV029 |
Dallas | Clampett Oil | TV026 |
No comments:
Post a Comment