The need now is to make the following result sets compact:
COL1 COL2 COL3
---------- ---------- ----------
1
2
3
4
5
6
7
8
9
Ten
One
A
COL1 COL2 COL3
---------- ---------- ----------
1 7 11
2 8 12
3 9
4 10
5
6
drop table test;
CREATE TABLE Test (col1 number,col2 number,col3 number);
INSERT into test values (1,null,null);
INSERT into test values (2,null,null);
INSERT into test values (3,null,null);
INSERT into test values (4,null,null);
INSERT into test values (5,null,null);
INSERT into test values (6,null,null);
INSERT into test values (null,7,null);
INSERT into test values (null,8,null);
INSERT into test values (null,9,null);
INSERT into test values (null,10,null);
INSERT into test values (null,null,11);
INSERT into test values (null,null,12);
Commit
Sql> select * from test;
COL1 COL2 COL3
---------- ---------- ----------
1
2
3
4
5
6
7
8
9
10
11
12
the idea is to isolate each column and then make a left connection:
with T1 as (select RowNum rn,col1 from Test where col1 is isn't null),
T2 as (select RowNum rn,col2 from test where col2 are NOT null),
T3 as (select RowNum RN, Col3 from test where col3 are NOT null)
Select Col1,col2,col3 from T1,t2,t3 where T1.RN=T2.RN (+) and T2.rn=t3.rn (+) ;
Order by T1.rn;
COL1 COL2 COL3
---------- ---------- ----------
1 7 11
2 8 12
3 9
4 10
5
6
The diversion of data--becomes compact