select id,month from table where month>3 union all select id,month from table where month<=3
create table test(id varchar(10),month int) insert test select '01',1 union all select '01',2 union all select '01',3 union all select '01',4 union all select '01',5 union all select '01',6 union all select '01',7 union all select '01',8 union all select '01',9 union all select '01',10 union all select '01',11 union all select '01',12select * from test order by case month when 1 then 12 when 2 then 13 when 3 then 14 else month end
union all
select id,month from table where month<=3
insert test select '01',1
union all select '01',2
union all select '01',3
union all select '01',4
union all select '01',5
union all select '01',6
union all select '01',7
union all select '01',8
union all select '01',9
union all select '01',10
union all select '01',11
union all select '01',12select * from test
order by
case month when 1 then 12
when 2 then 13
when 3 then 14
else month end
---------- -----------
01 4
01 5
01 6
01 7
01 8
01 9
01 10
01 11
01 12
01 1
01 2
01 3
原来是 union all 的问题 谢谢大家这么快解决 帖子地马上结