2013-10-01 113 views

回答

1
WITH t AS 
    (SELECT 1001 studentid, 'john' NAME FROM dual 
    UNION ALL 
    SELECT 1002, 'kane' FROM dual 
    ) 
SELECT * FROM (
SELECT studentid, NAME FROM t) 
pivot (max(studentid) for name in ('john' John, 'kane' Kane)); 
+0

嗨 感謝。我是這個oracle sql的新手。我不寫很多疑問,但偶爾需要。您能否請您解釋轉換背後的邏輯和您的查詢 – michael

+0

您可以閱讀使用「PIVOT」子句,請參閱文檔和鏈接,例如:http://www.oracle.com/technetwork/articles/sql/11g-pivot-097235 .html,http://www.oracle-base.com/articles/11g/pivot-and-unpivot-operators-11gr1.php – ajmalmhd04