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

  • Learn T-SQL Querying
  • Pedro Lopes Pam Lahoud
  • 113字
  • 2021-06-24 14:38:10

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:

主站蜘蛛池模板: 斗六市| 云南省| 都匀市| 白山市| 任丘市| 日土县| 徐闻县| 沛县| 伊宁市| 金乡县| 正蓝旗| 定南县| 嘉义县| 延寿县| 黄龙县| 五河县| 盐源县| 海兴县| 锡林郭勒盟| 江城| 汝州市| 安康市| 彩票| 宁海县| 庄浪县| 阜平县| 高要市| 四川省| 江川县| 子长县| 会泽县| 南漳县| 沾化县| 桂阳县| 南澳县| 淮安市| 翁牛特旗| 凌海市| 灵石县| 沙湾县| 金门县|