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!

Generate rows based on column value?

Lennert_bruinApr 15 2013 — edited Apr 15 2013
Hi All,

I would like to know if there is a function that can help me in generating rows based on a column value and, if so, which one. I'm on version 11.2.0.3.0

e.g. I have this table data:
ID M A C
1 5 3 5
2 9 2 3

Where ID is a unique ID of the record and the column C contains the number of records I would like to have returned for that ID. In this example, the record with ID 1 would be repeated 5 times and the record with id 2 would be repeated 3 times. The result would look like this:

ID M A C
1 5 3 5
1 5 3 5
1 5 3 5
1 5 3 5
1 5 3 5
2 9 2 3
2 9 2 3
2 9 2 3

The C column contains the number of record repetitions and is defined as a positive integer >= 1.

Of course, in real life the table contains (at this moment) 41 M number of records and the value of C can varies between 1 and 554, so hardcoding on the above example values is not possible.

Any pointers in the right direction are appreciated.

Regards,
Lennert
This post has been answered by BluShadow on Apr 15 2013
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 13 2013
Added on Apr 15 2013
5 comments
1,346 views