如何通过后面的示例将多列转换为行编码?对于解决方案,我检查了许多样本,例如数据透视,解码等,但我没有达到绝对解决方案。
+---------+---------+---------+---------+
| COL_1 | COL_2 | COL_3 | COL_4 |
+---------+---------+---------+---------+
I wanna make columns like this;
+---------+
| COL_1 |
+---------+
| COL_2 |
+---------+
| COL_3 |
+---------+
| COL_4 |
+---------+
Run Code Online (Sandbox Code Playgroud)
也许你想要unpivot?
with demo as ( select 1 as col1, 2 as col2, 3 as col3, 4 as col4 from dual )
select * from demo
unpivot
( colvalue for col in (col1, col2, col3, col4) );
COL COLVALUE
---- ----------
COL1 1
COL2 2
COL3 3
COL4 4
4 rows selected.
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4802 次 |
| 最近记录: |