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!

Need help with select statement with child rows going into columns instead of rows

TC-ArmyOct 21 2014 — edited Oct 22 2014

Hi everyone!

I have a requirement to put child records into columns.

With data something like this:

Table name: parents

Column 1: parent_id

Column 2: first_name

column 3: last_name

Table name: children

column 1: child_id

column 2: parent_id

column 3: first_name

column 4: last_name

Table 1 data:

1  john smith

2  grizzly adams

Table 2 data:

3  1  jack smith

4  1  jill smith

5  2  grizzJr adams

6 2  goldielox adams

7 2  grettle adams

Looking for data output to be like this:

Header 1Header 2Header 3Header 4Header 5Header 6Header 7Header 8Header 9Header 10Header 11Header 12Header 13
1johnsmith3jacksmith4jillsmith
2grizzlyadams5grizzJradams6goldieloxadams7grettleadams

How do I dynamically move the children into columns to the right of the parent table?

Thanks so much!!!

Tim

This post has been answered by Frank Kulash on Oct 21 2014
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 19 2014
Added on Oct 21 2014
8 comments
2,439 views