日期:2014-05-17 浏览次数:20790 次
with t1 as
(
select 1 id,date'2012-11-08' time,'100' balance from dual
union all
select 2 id,date'2012-11-10' time,'80' balance from dual
union all
select 3 id,date'2012-11-11' time,'70' balance from dual
)
select t.t_date,nvl(balance,(select balance from t1 where time = (select max(time) from t1 where time <= t_date))) balance
from
(
select m_date+level-1 t_date
from (select min(time) m_date from t1)
connect by level <= to_date('2012-11-15','yyyy-mm-dd')-m_date+1
) t left join t1 on t_date = time
order by t_date
t_date balance
----------------------------------
1 2012/11/8 100
2 2012/11/9 100
3 2012/11/10 80
4 2012/11/11 70
5 2012/11/12 70
6 2012/11/13 70
7 2012/11/14 70
8 2012/11/15 70