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
如何实现!!!!帮忙!!!
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
如何实现!!!!帮忙!!!
试试?
order by
(case when hour >= 10 then 1 else 2 end);
(case when hour >= 10 then hour - 24 else hour end);
http://school.itzcn.com/special-spid-35.html
上面讲解的比较详细,
希望对楼主有所帮助。
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;
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