表中数据:年度    月份   小时  分钟
Nendo Gatsudo Jikan Funkan 
17 1 148 50 
17 2 156 40 
17 3 172 20 
17 4 156 40 
17 5 148 50 
17 6 172 20 
17 7 156 40 
17 8 172 20 
17 9 156 40 
17 10 156 40 
17 11 156 40 
17 12 156 40 要求返回结果: Nendo Gatsudo Jikan Funkan 
17 4 156 40 
17 5 148 50 
17 6 172 20 
17 7 156 40 
17 8 172 20 
17 9 156 40 
17 10 156 40 
17 11 156 40 
17 12 156 40 
17 1 148 50 
17 2 156 40 
17 3 172 20 
也就是:表里面数据的月份从1月份到12月份
返回结果,要求从4月份到来年的3月份
请赐教!!!

解决方案 »

  1.   

    select * from 表 
    order by Nendo asc,
             abs(Gatsudo-4) asc
      

  2.   

    楼上:用你的办法查询得出下面的结果,显然不正确。
    Nendo Gatsudo Jikan Funkan
    17 4 156 40
    17 3 172 20
    17 5 148 50
    17 6 172 20
    17 2 156 40
    17 7 156 40
    17 1 148 50
    17 8 172 20
    17 9 156 40
    17 10 156 40
    17 11 156 40
    17 12 156 40
      

  3.   

    如果你用SQLSever
    select * from 表 
    order by Nendo asc,
             (case when Gatsudo<4 then Gatsudo+12 else Gatsudo end ) asc
      

  4.   

    crycoming(瞎编):
    我只是取出了一年的数据,当然还有15,16,18,19等等
      

  5.   

    winehero(编程人生):我用的是VB6,ACCESS2000
      

  6.   

    select Nendo, Gatsudo,Jikan,Funkan from (select *,iif(Gatsudo<=3,Gatsudo+12,Gatsudo) as ord from tbl) as T order by Nendo,Gatsudo
      

  7.   

    (select * from 表
    where Gatsudo>3 order by Gatsudo asc
    union
    select * from 表
    where Gatsudo<4 order by Gatsudo asc) 
    order by Nendo asc
      

  8.   

    select * from 表 A order by (A.Gatsudo+9)%13
      

  9.   

    conrad_wan(pineapple)高手也
    我写的苯
    select * from 表 A  order by case Gatsudo when 1  then 20+b when 2 then 20+b when 3 then 20+b else Gatsudo end
      

  10.   

    select * from 表 order by Nendo asc,iif(Gatsudo >3 ,Gatsudo -13,Gatsudo ) asc
    这里的数值13为大于或者等于最大月份12的任何数值即可.
      

  11.   

    Nendo Gatsudo Jikan Funkan 
    是不是给TMD小RB做?
      

  12.   

    select * from 表 where (Gatsudo>3 and Nendo=当年年度)
    union
    select * from 表 where (Gatsudo<4  and Nendo=当年年度+1)
      

  13.   

    用conrad_wan(pineapple):
    的方法问题解决。
    select * from 表 A order by (A.Gatsudo+9)%13不过在ACCESS中要改成这样:
    select * from 表 A order by (A.Gatsudo+9) mod 13
    非常感谢!