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!

Conditional transpose of column data into rows

user555994Jul 26 2013 — edited Jul 26 2013

Hello PL/SQL Gurus/experts,


I am using Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production version
I have following table -

drop table t2;

create table t2(BATot,Ly_BATot,LLy_BATot,BScTot,Ly_BScTot,LLy_BScTot,BAMSTot,Ly_BAMSTot,LLy_BAMSTot) as select
5000,2000,12600,20000,45600,35000,45000,56000,65000 from dual ;

select null class, batot,ly_batot,lly_batot,bsctot,ly_bsctot,lly_bsctot,bamstot,ly_bamstot,lly_bamstot from t2;

Simple DML I am using -

SELECT * FROM T2;

C      BATOT   LY_BATOT  LLY_BATOT     BSCTOT  LY_BSCTOT LLY_BSCTOT    BAMSTOT LY_BAMSTOT LLY_BAMSTO
- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
        5000       2000      12600      20000      45600      35000      45000      56000       65000


1 rows selected.

Oytput Data i am expecting in the form of conditional transpose -

Class  Tot  LyTot  LLYTot     
-----   ------   --------- -------
BA 5000  2000  12600
BSc  20000  45600  35000
BAMS 45000  56000  65000
Total 70000  103600  112600

4 rows selected.

Kindly help me and i want to thank you in advance for your valuable time and effort.

This post has been answered by user555994 on Jul 26 2013
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 23 2013
Added on Jul 26 2013
7 comments
763 views