oracle how to transpose columns into rows without UNION

情到浓时终转凉″ 提交于 2019-12-31 04:42:21

问题


Assume, i have 4 columns in a table

id | col1 | col2 | col3 

now i want to transpose that into one column but in 4 rows:

result
-------
someid
col1data
col2data
col3data

How can i achieve that? Thanks!


回答1:


This can be done using unpivot.

select result 
from tablename
unpivot (result for colnames in (id,col1,col2,col3))


来源:https://stackoverflow.com/questions/39450776/oracle-how-to-transpose-columns-into-rows-without-union

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!