日期:2014-05-17 浏览次数:20619 次
select *
from A
order by B ,case when B = 0 then C else 1 end,case when B = 0 then D else 1 end,
case when B = 1 then C else 0 end desc,case when B = 1 then D else 0 end desc
drop table A
/*
id B C D
-------------------------
1 0 1 2
2 0 1 3
7 0 1 4
6 0 2 1
5 1 4 4
3 1 3 6
4 1 3 5
*/