各为大虾,帮助一下小弟
我有一个表,记录:
id c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 列名
2 a b c d e f g h j k 列值
3 h i j k l m n o p q 列值
我现在想把行转化成列,如何写:
转后如
2 c1 a
2 c2 b
2 c3 c
2 c4 d
.
.
.
.
2 c10 k
3 c1 h
3 c2 i
3 c3 j
3 c4 k
.
.
.
.
3 c10 q
Access 查询行记录如何转换成列?
答案:2 悬赏:60
解决时间 2021-03-22 11:19
- 提问者网友:纹身骑士
- 2021-03-21 21:03
最佳答案
- 二级知识专家网友:邪性洒脱
- 2021-03-21 21:47
--没有什么捷径,只能枚举每一列:
select id,ca='c1',cb=c1 from table1 union
select id,ca='c2',cb=c2 from table1 union
select id,ca='c3',cb=c3 from table1 union
select id,ca='c4',cb=c4 from table1 union
select id,ca='c5',cb=c5 from table1 union
select id,ca='c6',cb=c6 from table1 union
select id,ca='c7',cb=c7 from table1 union
select id,ca='c8',cb=c8 from table1 union
select id,ca='c9',cb=c9 from table1 union
select id,ca='c10',cb=c10 from table1
select id,ca='c1',cb=c1 from table1 union
select id,ca='c2',cb=c2 from table1 union
select id,ca='c3',cb=c3 from table1 union
select id,ca='c4',cb=c4 from table1 union
select id,ca='c5',cb=c5 from table1 union
select id,ca='c6',cb=c6 from table1 union
select id,ca='c7',cb=c7 from table1 union
select id,ca='c8',cb=c8 from table1 union
select id,ca='c9',cb=c9 from table1 union
select id,ca='c10',cb=c10 from table1
全部回答
- 1楼网友:摧毁过往
- 2021-03-21 23:24
建立交叉表,必须要有3个字段才可以。如图
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯