2011-09-07 78 views
0

查詢的結果我想知道我怎麼能寫一個Oracle SQL命令顯示查詢結果,而不是爲:如何轉從Oracle數據庫

column_name1 column_name2 column_name3 
result1_col1 result1_col2 result1_col3 
result2_col1 result2_col2 result2_col3 
... 

而是:

column_name1 result1_col1 result2_col1 ... 
column_name2 result1_col2 result2_col2 ... 
column_name3 result1_col3 result2_col3 ... 

我的oracle版本是11.1.0.7.0。

非常感謝!

+2

PIVOT可以將特定數量的行轉變爲列。如果你不想知道最終的列數,你需要編寫代碼來編寫代碼(又名動態sql)。 – MatBailie

+0

這是'PIVOT'所能做到的:http://www.oracle.com/technetwork/articles/sql/11g-pivot-097235.html – NullUserException

+0

[Transpose select with Oracle](http:// stackoverflow。 com/questions/1788011/transpose-select-results-with-oracle) –

回答

0

這個blog post of mine是相當古老的,但確實給出了一種動態生成樞軸查詢的方法。它是在PIVOT條款存在之前編寫的。