select id,month from table where month>3
union
select id,month from table where month<4

解决方案 »

  1.   

    應該用Union All,而不是Union
      

  2.   

    select id,month from table where month>3
    union all
    select id,month from table where month<=3
      

  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
      

  4.   

    id         month       
    ---------- ----------- 
    01         4
    01         5
    01         6
    01         7
    01         8
    01         9
    01         10
    01         11
    01         12
    01         1
    01         2
    01         3
      

  5.   

    我用的是union  哈哈哈
    原来是 union  all  的问题  谢谢大家这么快解决 帖子地马上结
      

  6.   

    union all 不进行重新排序,paoluo(一天到晚游泳的鱼) 是对的,学习了,谢谢!!!!