我的结果如下:
level_1_node level_2_node level_3_node level_4_node
Node 1 Node2 Node 3 Node 4
我想将其转换为:
Node
Node 1
Node 2
Node 3
Node 4
怎么做?
答案 0 :(得分:3)
您可以使用 Union
select "level_1_node" as Node from Table1
union
select "level_2_node" as Node from Table1
union
select "level_3_node" as Node from Table1
union
select "level_4_node" as Node from Table1
<强> SQL Fiddle 强>
答案 1 :(得分:3)
使用unpivot
表格运算符:
select value
from tablename
unpivot
(
value
for node in (level_1_node,
level_2_node,
level_3_node,
level_4_node)
);