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!

how to write this query for below output

913349Aug 13 2015 — edited Aug 16 2015

Hi All,

i am using oracle 11g.

I have  a table  emp_det

The table is having below columns and data.

Role_Name ,consumer_id ,location

IT                   1,2,3              QTP

HR                3,4,5               BDK

TECH           7,8,9                 SJP

IT                  9,7,9                NJP

expected result:

Role_Name_1   CONSUMER_ID_1  LOCATION_1  ROLE_NAME_2     CONSUMER_ID_2   LOCATION_2   ROLE_NAME_3  CONSUMER_ID_3     LOCATION_3

       IT                       1,2,3                      QTP              HR                           3,4,5                  BDK                   TECH                          7,8,9               SJP

       IT                       9,7,9                       NJP             null                            null                    null                       null                            null                 null

Here based on the role the  column will increase. if there there is 5 different roles are there  in that case 5*3 =15 column should be there.In above table emp_id  is there which is a unique column.

if there is a there is 4 role and one is repeated in that case data will come  like above.

please help me.i am not getting idea how to do it .

Regards

Damby

Message was edited by: 913349

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 11 2015
Added on Aug 13 2015
8 comments
952 views