oracle實現行列轉換

QL> select * from student;

 

       IDNAME        CHINESE       MATH   ENGLISH

--------- -------- ---------- ---------- ----------

        1A                90         70         80

        2B                80         70         90

        3C                80         90         70

 

 

select id,name,'chinese' 課程,chinese 分數

from student

union all

select id,name,'math' 課程,math 分數

from student

union all

select id,name,'english' 課程,english 分數

from student

 

 

 

        IDNAME     課程          分數

---------- -------- ------- ----------

         1A        chinese         90

         2B        chinese         80

         3C        chinese         80

         1A        math            70

         2B        math            70

         3C        math            90

         1A        english         80

         2B        english         90

         3C        english         70

 

已選擇9行。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章