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 group rows and display as single column, with the grouping row value as the column name

shiva_0004Nov 26 2014 — edited Nov 27 2014

Hi,

I have a situation like, I need to group data in rows and display as column, with the grouping row value as the column name.

With the below scenario, you will understand my requirement better,

Below is the EMP table structure with records.

EMPNOENAMEJOBMGRHIREDATESALCOMMDEPTNO
7369SMITHCLERK790212/17/198080020
7499ALLENSALESMAN76982/20/1981160030030
7521WARDSALESMAN76982/22/1981125050030
7566JONESMANAGER78394/2/1981297520
7654MARTINSALESMAN76989/28/19811250140030
7698BLAKEMANAGER78395/1/1981285030
7782CLARKMANAGER78396/9/1981245010
7788SCOTTANALYST756612/9/1982300020
7839KINGPRESIDENT11/17/1981500010
7844TURNERSALESMAN76989/8/1981150030
7876ADAMSCLERK77881/12/1983110020
7900JAMESCLERK769812/3/198195030
7902FORDANALYST756612/3/1981300020
7934MILLERCLERK77821/23/1982130010

I want to display the report as below,

It is like, I wanted to display set of Employees for each department, grouped under their respective jobs.

DEPTNOCLERKPRESIDENTMANAGERANALYSTSALESMAN
10MILLERKINGCLARK
20SMITH, ADAMSJONESSCOTT, FORD
30JAMESBLAKEALLEN, WARD, MARTIN, MARTIN, TURNER

I have no clue on where to start on this.

The DB version used in our organization is Oracle 10g.

Please help me in this.

Thank you all in adavnce.

Regards,

Shiva

This post has been answered by Frank Kulash on Nov 26 2014
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 25 2014
Added on Nov 26 2014
8 comments
3,104 views