create table test(ID int identity(1,1),a int,b int)
insert test(a,b)
select 3 ,1 union all
select 4 ,0 union all
select 5 ,0 union all
select 1 ,1 union all
select 2 ,0 union all
select 4 ,1 union all
select 6 ,1 union all
select 2 ,0 union all
select 3 ,1
--select * from test
select * from test
order by
case when b=1 then 0 else 1 end,
case when b=1 then a else id end desc,
id desc -- id为9与1的排序