declare @t table(s int) insert @t select 0 union all select 1 union all select 2select * from @t order by charindex(rtrim(s),'102')
0,2,1 SELECT 字段 FROM 表 ORDER BY CASE 状态标识字段 WHEN 0 THEN 0 WHEN 2 THEN 1 WHEN 1 THEN 2 END 2,0,1 SELECT 字段 FROM 表 ORDER BY CASE 状态标识字段 WHEN 2 THEN 0 WHEN 0 THEN 1 WHEN 1 THEN 2 END
declare @t table(s int) insert @t select 0 union all select 1 union all select 2select * from @t where s <> 1 union all select * from @t where s = 1
insert @t select 0
union all select 1
union all select 2select * from @t order by charindex(rtrim(s),'102')
SELECT 字段 FROM 表 ORDER BY CASE 状态标识字段 WHEN 0 THEN 0 WHEN 2 THEN 1 WHEN 1 THEN 2 END
2,0,1
SELECT 字段 FROM 表 ORDER BY CASE 状态标识字段 WHEN 2 THEN 0 WHEN 0 THEN 1 WHEN 1 THEN 2 END
insert @t select 0
union all select 1
union all select 2select * from @t where s <> 1
union all
select * from @t where s = 1