QUOTE:oralce11g的行转置实现
我仔细研究过,至今没发发现oracle有真正意义上的行列转置函数;
有的只是部分的行列转置;
11G:
CREATE TABLE T (ID NUMBER,A VARCHAR2(10),B VARCHAR2(10));
INSERT INTO T VALUES ( 1, '02' ,'03' );
INSERT INTO T VALUES ( 2, '05' ,'08' );
INSERT INTO T VALUES ( 3, 'oracle' ,'mysql');
select id, col, val
from t
unpivot ( val for col in (A,B) )
ID C VAL
---------- - ----------
1 A 02
1 B 03
2 A 05
2 B 08
3 A oracle
3 B mysql
6 rows selected.