select * from table1 查出的结果是24条  排序是hour
 hour值是0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15...到23
 
假如我页面传个10
要达到这个效果::
10,11....23,0,1,2,3,4,5,6,7,8,9
如何实现!!!!帮忙!!!

解决方案 »

  1.   

    select a,b,c,hour,(case when hour<10 then hour+25 else hour end) as hour1 from tble order by hour1;
    试试?
      

  2.   

    select * from t
    order by
    (case when hour >= 10 then 1 else 2 end);
      

  3.   

    用 union all   我知道了
      

  4.   

    完善一下select * from t order by
    (case when hour >= 10 then hour - 24 else hour end);
      

  5.   

    参考:
    http://school.itzcn.com/special-spid-35.html
    上面讲解的比较详细,
    希望对楼主有所帮助。
      

  6.   

    create or replace Procedure ReSortHour( v_hour number(8) )
    is
    begin
      select (case when hour < 24 - v_hour then hour + v_hour else hour - 24 + v_hour end) as hour1 from lyf_test order by hour;
    end;
      

  7.   

    order by (case when hour>=:hour then 1 else 2),hour
      

  8.   

    select hour from t order by (case when hour>=&hour then hour-24 else hour end);
      

  9.   

    select mod(hour+10,24) from table1 order by hour;
      

  10.   

    select *
      from (select * from table1 where hour >= 10 order by hour) t1
    union all
    select * from (select * from table1 where hour < 10 order by hour) t2