我正在努力将矩阵转换为可用的表,但是无法通过使用SQL并基本上重组整个文件的方式来提出创造性的方法
任何帮助/建议将不胜感激。
之前
A B C D
1 .5 .6 .7 .8
2 .9 1.0 1.1 1.2
3 1.3 1.4 1.5 1.6
4 1.7 1.8 1.9 2.0
之后
X Y Result
A 1 .5
A 2 .9
A 3 1.3
A 4 1.7
.....
答案 0 :(得分:1)
在MySQL中,最简单的方法可能是union all
:
select 'A' as x, col1 as y, A as result from t union all
select 'B' as x, col1 as y, B as result from t union all
select 'C' as x, col1 as y, C as result from t union all
select 'D' as x, col1 as y, D as result from t;