1

I want to invert the data in my table, i.e. convert a:

  1. Row to Column.
  2. Column to Row.

The actual table data is

                col1     col2
---------------------------------
row1              1        2
row2              3        4

Expected output :

                col1     col2
---------------------------------
row1              1        3
row2              2        4

I have tired with a normal select query but couldn't work out how to do this. Is it possible in PL/SQL?

Ben
  • 51,770
  • 36
  • 127
  • 149
JCRaja
  • 21
  • 4

1 Answers1

0
 (select * from (select a,b from t) pivot(sum(a) for b in(2,4)))

 union

 (select * from (select a,b from t) pivot(sum(b) for a in(1,3)));
Sai
  • 659
  • 4
  • 12
  • 21