如何在 Oracle 中获取 XXhr 完成日期

How to get XXhr completed date in Oracle

请帮助我使用 pl sql 获得以下输出。

date    hours   sum (has to be derived when querying out.)
1/1/2014    3   3
1/2/2014    2   5
1/3/2014    4   9
1/4/2014    5   14
1/5/2014    6   20
1/6/2014    2   22
1/7/2014    4   26
**1/8/2014  5   31**
1/9/2014    6   7  (previous day remainder 1 + 6)
1/10/2014   4   11
1/11/2014   8   19
1/12/2014   4   23
1/13/2014   5   28
**1/14/2014 8   36**
1/15/2014   3   9 (previous day remainder 6 + 3)
1/16/2014   4   13
1/17/2014   7   20
1/18/2014   3   23
1/19/2014   6   29
**1/20/2014 2   31**

期望的输出如下。

1/8/2014
1/14/2014
1/20/2014

期待您的快速帮助。

这是您所需输出的完整演示代码。

create  table dumt (tdate date,hours number);

insert all 
into dumt values('01-jan-2014',3)
into dumt values('2/jan/2014',2)
into dumt values('3/jan/2014',4)
into dumt values('4/jan/2014',5)
into dumt values('5/jan/2014',6)
into dumt values('6/jan/2014',2)
into dumt values('7/jan/2014',4)
into dumt values('8/jan/2014',5)
into dumt values('9/jan/2014',6)
into dumt values('10/jan/2014',4)
into dumt values('11/jan/2014',8)
into dumt values('12/jan/2014',4)
into dumt values('13/jan/2014',5)
into dumt values('14/jan/2014',8)
into dumt values('15/jan/2014',3)
into dumt values('16/jan/2014',4)
into dumt values('17/jan/2014',7)
into dumt values('18/jan/2014',3)
into dumt values('19/jan/2014',6)
into dumt values('20/jan/2014',2)
select * from dual;

commit;

select tdate 
from 
   (
    select tDATE,
    case when lag(the_sum) over (order by the_sum)>30 then 
    mod(lag(the_sum) over (order by the_sum),30)+hours 
    else the_sum end as tsp
    from (
            select tDATE,HOURS,
                  (sum(HOURS) over (order by tDATE)) the_sum 
            from dumt
         ) 
    )
    where tsp>=30;
select
  min(dt) keep (dense_rank last order by dt desc)
from (
       select
         dt,
         trunc(sum(hours) over (order by dt) / 30) bucket
       from
         tq84_hours
)
where bucket != 0
group by bucket;

工作示例@sqlfiddle