pivot,unpivot 行列互转

SELECT *

  FROM (SELECT "10_SAL", "20_SAL", "30_SAL"

          FROM (SELECT deptno, sal FROM scott.emp) pivot(SUM(sal) AS sal FOR(deptno) IN(10,

                                                                                        20,

                                                                                        30)

                                                         )

        ) unpivot(sal FOR deptno IN("10_SAL",

                                    "20_SAL",

                                    "30_SAL")

                  )

你可能感兴趣的:(PIVOT,Unpivot)