日期:2014-05-16 浏览次数:20998 次
select a_date,count(a_date) c_num from ( with t1 as( select date'2010-07-22' b_date,date'2010-09-15' e_date from dual union all select date'2010-07-22',date'2010-10-26' from dual ) select to_char(a_date,'yyyy-mm') a_date from ( SELECT ADD_MONTHS(DATE'2009-12-01',LEVEL) AS a_date FROM DUAL CONNECT BY LEVEL <= 12),t1 where a_date between ADD_MONTHS(b_date,-1) and e_date) group by a_date order by a_date a_date c_num -------------------------- 1 2010-07 2 2 2010-08 2 3 2010-09 2 4 2010-10 1