sql server如指定字段排序

方法一:利用order by+case when

select year,country,product,profit from sales

order by year,case when country='CHIAN' then 1 when country='US' then 2 end

方法二:利用order by+charindex

select year,country,product,profit from sales

order by year,charindex(country,'CHINA,US')

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章