SQL 将列转换为行 [英] SQL Convert column to row
本文介绍了SQL 将列转换为行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的表有以下列:
A | B | C | D | E | F
我想显示如下:
MyColumn | MyColumn2
A | B
C | D
E | F
如您所见,我想将列显示为具有自定义列名称的对.对是 A 列和 B 列、C 列和 D 列以及 C 列和 D 列.
As you can see i want to display the columns as pairs with a custom column name. The pairs are Column A and B, column C and D and column C and D.
推荐答案
select A as [Col 1], B as [Col 2] from table
union all
select C,D from table
union all
select E,F from table
这篇关于SQL 将列转换为行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文