order by case when 0 then 0 else 1 end desc,价格 asc --or order by case when 0 then 0 else 1 end desc,价格 desc
select * from tb order by case when 值=0 then 1 else 0 end
create table #ttttt (i int)insert #ttttt select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 0 select * from #ttttt order by case when i=0 then (select max(i)+1 from #ttttt) else i end i ----------- 1 2 3 4 5 6 0(7 行受影响)select * from #ttttt order by i desc i ----------- 6 5 4 3 2 1 0(7 行受影响)
select * from tb order by case when val = 0 then 1 else 2 end , val select * from tb order by case when val = 0 then 1 else 2 end , val desc
--or
order by case when 0 then 0 else 1 end desc,价格 desc
order by case when 值=0 then 1 else 0 end
create table #ttttt
(i int)insert #ttttt
select 1 union all
select 2 union all
select 3 union all
select 4 union all
select 5 union all
select 6 union all
select 0
select * from #ttttt
order by case when i=0 then (select max(i)+1 from #ttttt) else i end
i
-----------
1
2
3
4
5
6
0(7 行受影响)select * from #ttttt
order by i desc i
-----------
6
5
4
3
2
1
0(7 行受影响)
select * from tb order by case when val = 0 then 1 else 2 end , val desc