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!

To get the list of rows datas into a single row in different columns

2754423Apr 3 2017 — edited Apr 4 2017

Hi Team,

I have requirement where I need to get the list of multiple rows for a single record in the same table into different column set of that record. This data will gather all the data from the different rows and merge it into a single row with different column. Fields are added in a different table as these filed are dynamic and further fields can be added.

Table1

Attribute_key           Attribute_name

12                              Name

13                               Age

14                              Gender

15                              Occupation

table2

Record_key     Attribute_key     Attribute_value

1                        12                    XXX

2                        13                   21

3                        14                   Female

4                        15                  IT Engg

8                        12                    YYY

5                        13                   25

6                        14                   Male

7                        15                  CA

I want to get an output like this..

Name               Age     Gender       Occupation

XXX                21          Female               IT Engg

YYY                 25          Male                 CA

so that in future if we want to add a new attribute we can add a new record in the table attribute instead of adding a new column in the table2

Thanks in Advance

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 2 2017
Added on Apr 3 2017
31 comments
1,518 views