http://oraclecoder.com/tutorials/three-ways-to-transpose-rows-into-columns-in-oracle-sql--160
網站上面有很好範例,注意: The PIVOT and the UNPIVOT operators were introduced in Oracle version 11g.
Example # 1a: Transpose rows into columns using SUM and DECODE to summarize data
Example # 1b: Transpose rows into columns using MAX and DECODE – for non-summarized data
Example # 2: Transpose rows into columns using the Oracle PIVOT operator
Example # 3: Transpose rows into columns using WITH and sub SELECTS