1

我的结果如下:

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

怎么做?

4

2 回答 2

3

使用unpivot表运算符:

select value
from tablename
unpivot 
(
  value
  for node in (level_1_node, 
               level_2_node, 
               level_3_node, 
               level_4_node)
);
于 2013-07-04T10:45:45.727 回答
3

你可以使用联合

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小提琴

于 2013-07-04T10:43:05.410 回答