官术网_书友最值得收藏!

ORDER BY

The ORDER BY clause orders the results. The default order is ascending, meaning that the ASC keyword can be omitted. To produce the result set in descending order, DESC must be set explicitly. Building on the same example from the WHERE section, the following code block is used to explicitly present results in descending order of product name and location name:

SELECT P.Name AS ProductName, [PI].Quantity, L.Name AS LocationName
FROM Production.Product AS P
INNER JOIN Production.ProductInventory AS [PI] ON P.ProductID = [PI].ProductID
INNER JOIN Production.Location AS L ON [PI].LocationID = L.LocationID
WHERE P.Name LIKE 'Touring%'
ORDER BY P.Name DESC, L.Name DESC;

The following screenshot shows the results in the specified order:

主站蜘蛛池模板: 丹凤县| 河北区| 六盘水市| 长白| 忻城县| 永新县| 牡丹江市| 合肥市| 彭山县| 左权县| 思茅市| 保德县| 榆树市| 黔江区| 嘉义县| 福清市| 苗栗县| 商城县| 雷山县| 东乡| 克什克腾旗| 桦南县| 乌鲁木齐县| 沅江市| 朝阳县| 揭东县| 达尔| 临夏县| 宜兰市| 湘潭市| 抚州市| 温宿县| 南投县| 呈贡县| 长治县| 当涂县| 华亭县| 津市市| 施甸县| 水城县| 武城县|