-1

对此我深表歉意,但我之前的问题没有正确构图,所以创建另一个帖子。

我的问题类似于以下问题: http ://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:14582643282111

我需要编写内部查询,它将为我提供两个日期范围之间的日期列表到外部查询。

我的内部查询返回以下 2 行:

SELECT request.REQ_DATE, request.DUE_DATE FROM myTable where id = 100

REQ_DATE           DUE_DATE
    3/19/2013          3/21/2013 
    3/8/2013           3/8/2013

所以我需要内部查询,它将以下日期返回给外部查询:

3/19/2013
3/20/2013
3/21/2013
3/8/2013

上面帖子中的答案具有硬编码的开始日期和结束日期,就我而言,它来自其他表。所以我正在尝试编写这样的查询,但它不起作用:</p>

Select * from outerTable where  my_date in
(   
    select to_date(r.REQ_DATE) + rownum -1 from all_objects, 
    (   
         SELECT REQ_DATE, DUE_DATE
         FROM    myTable where id = 100
    )  r                              
    where rownum <= to_date(r.DUE_DATE,'dd-mon-yyyy')-to_date(r.REQ_DATE,'dd-mon-yyyy')+1;
)
4

1 回答 1

0
with 
T_from_to as (
   select
      trunc(REQ_DATE) as d_from, 
      trunc(DUE_DATE) as d_to
   FROM myTable 
   where id = 100
),
T_seq as (
   select level-1 as delta
   from dual
   connect by level-1 <= (select max(d_to-d_from) from T_from_to)
)
select distinct d_from + delta
from T_from_to, T_seq
where d_from + delta <= d_to
order by 1
于 2013-03-08T20:15:57.503 回答