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!

Rows to columns

jvjmohanMay 19 2011 — edited May 19 2011
Hi all

I have data in this format

Table 1 - Manager

Name | ID
Mgr1 | 1
Mgr2 | 2

Talbe 2 - Employee

EName | EID | MgrID
Emp1 | 1 | 1
Emp2 | 2 | 1
Emp3 | 3 | 1
Emp4 | 4 | 1
Emp11 | 11 | 2
Emp12 | 12 | 2
Emp13 | 13 | 2
Emp14 | 14 | 2

Join is Employee.mgrid = Manager.id

I need the output in this format

Name | ID | Employees
Mgr1 | 1 | Emp1,Emp2 ,Emp3 ,Emp4
Mgr2 | 2 | Emp11,Emp12 ,Emp13 ,Emp14

I am working Oracle 10g and have to use only sql. If there is an existing thread please direct me.

I have checked for xmlagg but its not allowed in our setup.

Thanks,
Vijay
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 16 2011
Added on May 19 2011
8 comments
696 views