日期:2014-05-17 浏览次数:20874 次
select sday + level - 1
from (select to_date('2013-1-1', 'yyyy-mm-dd') sday,
to_date('2013-1-5', 'yyyy-mm-dd') eday
from dual) t
connect by level <= t.eday - t.sday + 1
--举例:求t2(t_date,t_num)里面的每天合计数量
select t1.d_date,nvl(sum(t2.t_num),0) t_num
from
(
select date'2013-01-01'+level-1 d_date
from dual
connect by level <= date'2013-01-05' - date'2013-01-01' + 1
) t1 left join t2 on t1.d_date = t2.t_date
group by t1.d_date
order by t1.d_date