sql语句怎么 按指定的某列的摸个值排序
sql语句如何 按指定的某列的摸个值排序如题:select * from dbo.Archives_CM where cmcode37078501010000
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' --上面不小心多了个符号。