当前位置: 代码迷 >> Sql Server >> sql语句怎么 按指定的某列的摸个值排序
  详细解决方案

sql语句怎么 按指定的某列的摸个值排序

热度:91   发布时间:2016-04-24 23:04:25.0
sql语句如何 按指定的某列的摸个值排序
如题:

select * from dbo.Archives_CM where cmcode='3707850101000009'  order by HumanCode='03'
按HumanCode='03'的那一列排序

------解决方案--------------------
如果HumanCode 固定只有那么几个,可以用Case


select * from dbo.Archives_CM where cmcode='3707850101000009'  
order by case when HumanCode='03' then 1
                   else 2 end asc

------解决方案--------------------
select * from dbo.Archives_CM where cmcode='3707850101000009'  and HumanCode='03'
union all
select * from dbo.Archives_CM where cmcode='3707850101000009'  and HumanCode=<>'03'
------解决方案--------------------
select * from dbo.Archives_CM where cmcode='3707850101000009'  and HumanCode='03'
union all
select * from dbo.Archives_CM where cmcode='3707850101000009'  and HumanCode<>'03' --上面不小心多了个符号。
  相关解决方案