日期:2014-05-17  浏览次数:20810 次

sql语句:如何统计1月至5月每时段的发案数量,每时段是指将24小时分割位12段
也就是说,0-2,2-4,……,22-24
请帮帮忙,谢谢

------解决方案--------------------
select count(case when
to_date(to_char( ' "+txtStartDate+ " ', 'yyyy-MM-dd HH24:mi '), 'hh24mi ') > = '0000 '
and to_date(to_char( ' "+txtEndDate+ ', 'yyyy-MM-dd HH24:mi '), 'hh24mi ') <= '0020 '
then 1
else null end )
from table