Similar to UNPIVOT functionality in Oracle 10g
Problem Description
--------------------------
One table is having DNO, LN1, LN2 --- LN89 columns along with other columns. Either 0 or 1 will be stored in LN1 to LN89 columns for each and every DNO.
Please go through below sample data for better understanding
Table
-------
CREATE TABLE COL2ROW
(DNO NUMBER(6), LN1 NUMBER(1),
LN2 NUMBER(1),LN3 NUMBER(1),
LN4 NUMBER(1),LN5 NUMBER(1),
LN6 NUMBER(1),LN7 NUMBER(1),
LN8 NUMBER(1),LN9 NUMBER(1),LN10 NUMBER(1)) ;
Sample Data
------------
insert into col2row values( 111, 1,1,0,0,0,0,0,0,0,1);
insert into col2row values( 222, 0,1,1,1,0,1,0,0,0,0);
insert into col2row values( 333, 0,0,1,1,0,0,0,0,0,0);
insert into col2row values( 444, 1,0,0,1,0,0,0,0,1,0);
insert into col2row values( 555, 1,1,0,1,1,0,0,0,1,0);
insert into col2row values( 666, 0,0,0,1,1,1,0,0,1,0);
--------------------------
One table is having DNO, LN1, LN2 --- LN89 columns along with other columns. Either 0 or 1 will be stored in LN1 to LN89 columns for each and every DNO.
Please go through below sample data for better understanding
Table
-------
CREATE TABLE COL2ROW
(DNO NUMBER(6), LN1 NUMBER(1),
LN2 NUMBER(1),LN3 NUMBER(1),
LN4 NUMBER(1),LN5 NUMBER(1),
LN6 NUMBER(1),LN7 NUMBER(1),
LN8 NUMBER(1),LN9 NUMBER(1),LN10 NUMBER(1)) ;
Sample Data
------------
insert into col2row values( 111, 1,1,0,0,0,0,0,0,0,1);
insert into col2row values( 222, 0,1,1,1,0,1,0,0,0,0);
insert into col2row values( 333, 0,0,1,1,0,0,0,0,0,0);
insert into col2row values( 444, 1,0,0,1,0,0,0,0,1,0);
insert into col2row values( 555, 1,1,0,1,1,0,0,0,1,0);
insert into col2row values( 666, 0,0,0,1,1,1,0,0,1,0);
0