Home [SQL] 指定顯示順序(Order By)
Post
Cancel

[SQL] 指定顯示順序(Order By)

Order By

預設ASC排序

  • ASC升幕
  • DESC降幕

以姓名拼音順序來輸出負責人姓名

1
2
3
4
--以姓名拼音順序來輸出負責人姓名
select [負責人姓名]
from [dbo].[負責人清單]
order by [姓名拼音]

以升幕排列姓名拼音;降幕排列負責人姓名

也可以指定複數的行來排序

1
2
3
4
--以升幕排列姓名拼音;降幕排列負責人姓名
select [姓名拼音], [負責人姓名]
from [dbo].[負責人清單]
order by [姓名拼音] asc,  [負責人姓名] desc
This post is licensed under CC BY 4.0 by the author.