Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Duplicate rows on condition

bin wangJul 31 2019 — edited Jul 31 2019

Dear All,

I would like to duplicate table rows basing a condition.

idvalue
1X1
2X2
3X1
4X3
5X4

for example, I want to duplicate 2 times more each row having "value" = "X1" to obtain the result below :

idvalue
1X1
1X1
1X1
2X2
3X1
3X1
3X1
4X3
5X4

I tried to do that using connect by level, but I can't specify condition on "value" = "X1" :

with duplic as (select level l from dual connect by level <= 3)

select *

from my_table, duplic

order by id;

Thank you for your help!

Best regards

Comments
Post Details
Added on Jul 31 2019
4 comments
2,294 views