当前位置:首页 » 编程语言 » sqlserver列转行

sqlserver列转行

发布时间: 2023-03-01 21:31:08

A. sql 列转行

CREATE TABLE T1(A NUMBER,
b NUMBER,
c NUMBER,
d NUMBER,
e NUMBER);
insert into t1 values(1,2,3,4,5);
select * from t1;
select decode(A,1,'A',null) KEY ,decode(A,1,1,null) VALUE
from t1
union all
select decode(B,2,'B',null),decode(B,2,2,null)
from t1
union all
select decode(C,3,'C',null),decode(C,3,3,null)
from t1
union all
select decode(D,4,'D',null),decode(D,4,4,null)
from t1
union all
select decode(E,5,'E',null),decode(E,5,5,null)
from t1;

热点内容
delphijava 发布:2024-11-07 12:40:35 浏览:464
sqlserver查询数据 发布:2024-11-07 12:40:28 浏览:6
javaj2ee 发布:2024-11-07 12:26:17 浏览:787
hmcl服务器地址怎么写 发布:2024-11-07 12:26:10 浏览:542
北京一区服务器ip地址 发布:2024-11-07 12:12:54 浏览:316
dll加密反编译 发布:2024-11-07 12:10:40 浏览:92
lol如何设置服务器忙 发布:2024-11-07 12:04:04 浏览:547
发票价算法 发布:2024-11-07 11:59:02 浏览:603
使命召唤如何退款安卓微信 发布:2024-11-07 11:32:38 浏览:822
优酷上传音乐 发布:2024-11-07 11:28:14 浏览:733