比较简单的换行,就是把年的数据合并起来了,再加上判断是几月的数据,一相加即可.聚合+判断 方法一:group by +sum()+case when 做法 select 年, sum(case when 月=1 then 值 else 0 end) as m1, sum(case when 月=2 then 值 else 0 end) as m2, sum(case when 月=3 then 值 else 0 end) as m3, sum(case when 月=4 then 值 else 0 end) as m4 from cook group by 年 order by 年 方法二:group by +sum()+if() select 年, sum(if(月=1,值,0)) as m1, sum(if(月=2,值,0)) as m2, sum(if(月=3,值,0)) as m3, sum(if(月=4,值,0)) as m4 from cook group by 年 order by 年