Transpose select results with Oracle
问题 my question is, with some background: I have to generate some sql queries based on the table metadata (column format), and the result is something like: TABLENAME1|COL1 TABLENAME1|COL2 TABLENAME2|COL1 TABLENAME2|COL2 TABLENAME2|COL3 TABLENAME3|COL1 TABLENAME4|COL1 TABLENAME4|COL2 ... /*some other 1800 rows */ (Yeah, it's ordered.) What I need is to transpose this data, based on the first column, so the expected output would be: TABLENAME1|COL1|COL2|NULL TABLENAME2|COL1|COL2|COL3 TABLENAME3