日期:2014-05-17 浏览次数:21069 次
with t1 as
(
select 10001 c1,10005 c2,5 c3,100 c4 from dual
union all
select 10007 c1,10012 c2,6 c3,200 c4 from dual
)
select distinct c1+level-1 c1,c4
from t1
connect by level <= c2 - c1 + 1
order by c1
c1 c4
---------------------------
1 10001 100
2 10002 100
3 10003 100
4 10004 100
5 10005 100
6 10007 200
7 10008 200
8 10009 200
9 10010 200
10 10011 200
11 10012 200
------解决方案--------------------
可以这样实现
select distinct rt.beginresid - 1 + level, rt.price from resource_tab rt connect by level < rt.count + 1
------解决方案--------------------
with cte as(
select '10001' BeginResId, '10005' EndResId, 5 count, 100 price from dual
union all
select '10007', '10012', 6, 200 from dual
)
select beginresid+level-1 resid,price from cte
connect by level<=count and prior price=price and
prior dbms_random.value is not null;
结果为:
RESID PRICE
---------------------- ----------------------
10001 100
10002 100
10003 100
10004 100
10005 100
10007 200
10008 200
10009 200
10010 200
10011 200
10012 200
11 rows selected