行轉列
select * from (select name, nums from demo/*任意查詢語句*/) pivot (sum(nums) for name in ('測試1' 測試1, '測試2', '測試3'));
也可以用wm_concat函數
列轉行
select id , name,xx,demo from Fruit unpivot (demo for xx in (q1, q2, q3) )
demo是數據列轉行以后的字段名
xx 是原來那些字段顯示的字段名
in里面是要轉行的列名