【转置】使用mysql转置表格行和列
1、原始表
2、查询结果表
3、查询语句
1 SELECT
2 year1,
3 SUM( CASE WHEN mon= 1 THEN account END ) AS m1,
4 SUM( CASE WHEN mon= 2 THEN account END ) AS m2,
5 SUM( CASE WHEN mon = 3 THEN account END ) AS m3,
6 SUM( CASE WHEN mon = 4 THEN account END ) AS m4 FROM
8 dt
9 GROUP BY year1;