麻烦点的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
(
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
能用jdbc写的。或者ibatis里面的sql语句(引用函数也行),你这
把前面造数据的部分删了,怎么不能在JDBC里执行?ibatis也就多个<= 用cdata 不也能写到xml里面去了吗?