我有一张这样的表:
但我看起来像这样。如何使用mysql workbench语法更改它?
答案 0 :(得分:0)
select max(case when id = 1 then col1 end) as `10`,
max(case when id = 2 then col1 end) as `20`,
max(case when id = 3 then col1 end) as `30`
from ((select id, `one`as col1, 1 as col2 from t1) union all
(select id, two, 2 as col2 from t1) union all
(select id, three, 3 as col2 from t1) union all
(select id, four, 4 as col2 from t1) union all
(select id, five, 5 as col2 from t1)
) temp
group by col2;