例如,我有两行
id|amount
1|4
2|1
如何复制超过1的行?
1|1
1|1
1|1
1|1
2|1
答案 0 :(得分:3)
使用connect by:
可以轻松实现with sample_data as (select 1 id, 4 amount from dual union all
select 2 id, 1 amount from dual)
select id, 1
from sample_data
connect by prior id = id
and prior dbms_random.value is not null
and level <= amount;
ID 1
---------- ----------
1 1
1 1
1 1
1 1
2 1