2016-12-16 46 views

回答

1

您正在查找unpivot

select * from t 
unpivot (
      v for k in ("NAME","AGE","GENDER","STATUS") 
     ) u 

如果年齡列是整數,則可能有類型不匹配。在這種情況下,將其轉換爲字符之前unpivoting。

select * 
from (select id,name,to_char(age) age,gender,status from t) t 
unpivot (
     v for k in ("NAME","AGE","GENDER","STATUS") 
     ) u