oracle如何在不使用UNION的情况下将列转置为行 [英] oracle how to transpose columns into rows without UNION
本文介绍了oracle如何在不使用UNION的情况下将列转置为行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设,我在一个表中有4列
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!
推荐答案
这可以使用unpivot
完成.
select result
from tablename
unpivot (result for colnames in (id,col1,col2,col3))
这篇关于oracle如何在不使用UNION的情况下将列转置为行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文