日期:2014-05-17 浏览次数:20856 次
with a as( select '张三' xm,to_date('2012-04-01','yyyy-mm-dd') ksrq,to_date('2012-04-03','yyyy-mm-dd') jsrq from dual union all select '李四',to_date('2012-04-01','yyyy-mm-dd'),to_date('2012-04-02','yyyy-mm-dd') from dual union all select '王五',to_date('2012-04-05','yyyy-mm-dd'),to_date('2012-04-06','yyyy-mm-dd') from dual ) select count(1), ksrq + rn - 1 from a, (select rownum rn from dual connect by rownum <= (select max(jsrq - ksrq) from a)) t where a.jsrq >= a.ksrq + rn - 1 group by ksrq + rn - 1 COUNT(1) KSRQ+RN-1 ---------- ----------- 2 2012-4-1 2 2012-4-2 1 2012-4-3 1 2012-4-5 1 2012-4-6
------解决方案--------------------
--怎么是个重复的帖子啊?
select count(日期),日期 from ( select 开始日期 日期 from A union all select 结束日期 日期 from A ) group by 日期
------解决方案--------------------