【发布时间】:2021-11-24 13:36:36
【问题描述】:
当我按CreditRating 订购时,它是按照描述的顺序,所以“高于平均水平”排在第一位。我要下单
- 高级
- 优秀
- 高于平均水平
- 等
select VendorID as FournisseurID,
V.Name as NomFournisseur,
CreditRating =
case
when CreditRating = '1' then 'Superior'
when CreditRating = '2' then 'Excellent'
when CreditRating = '3' then 'Above average'
when CreditRating = '4' then 'Average'
when CreditRating = '5' then 'Below average'
end,
sum(TotalDue) as TotalDû
from Purchasing.ProductVendor PV
Order by CreditRating, V.Name
【问题讨论】:
-
如果
CreditRating是int数据类型,那么您不应该使用''来比较数字
标签: sql sql-server sql-order-by