Oracle Sql 转置 Table

Oracle Sql Transpose Table

我想转置下面的table

NAME                  BRUT      MALIYET     NET
------------------------------------------------
BAZ ÜCRET             16944,44  16944,44    16944,44
MESAİ                 0         0           0
SABİT PRİMLER         6452,46   6452,46     6452,46
PERFORMANS PRİMİ      0         0           0
DİĞER ÖDEMELER        0         0           0
İŞÇİ SGK ÖDEMESİ      3278,27   3278,27 
İŞVEREN SGK ÖDEMESİ             4314,35 

NAME   BAZ ÜCRET  MESAİ    SABİT PRİMLER    PERFORMANS PRİMİ   DİĞER ÖDEMELER   İŞÇİ SGK ÖDEMESİ  İŞVEREN SGK ÖDEMESİ 
 ----------------------------------------------------------------------------------------------------------------------    
NET      16944,44   0       6452,46           0                  0                NULL            NULL
BRUT     16944,44   0       6452,46           0                  0                3278,27         NULL         
MALIYET  16944,44   0       6452,46           0                  0                3278,27         4314,35

如何旋转多列?感谢您的帮助

您可以连续申请UNPIVOT and PIVOT作为

WITH t AS
(
SELECT *
  FROM tab  --> this stands for your original table
UNPIVOT (deger FOR "Odeme Turu" IN ( brut, maliyet, net ))
)
SELECT * 
  FROM t
 PIVOT (MAX(deger) FOR name IN ('BAZ UCRET'           AS "Baz Ucret",
                                'MESAI'               AS "Mesai",
                                'SABIT PRIMLER'       AS "Sabit Primler", 
                                'PERFORMANS PRIMI'    AS "Performans Primi",
                                'DIGER ODEMELER'      AS "Diger Odemeler",
                                'ISCI SGK ODEMESI'    AS "Isci SGK Odemesi",
                                'ISVEREN SGK ODEMESI' AS "Isveren SGK Odemesi") )

Demo