select year, sum(case month when 1 then amount else 0 end) as m1, sum(case month when 2 then amount else 0 end) as m2, sum(case month when 3 then amount else 0 end) as m3, sum(case month when 4 then amount else 0 end) as m4
from table group by year
http://blog.csdn.net/xiangnideshen/article/details/39076339
http://blog.163.com/yibei_kukafei/blog/static/30021021201223195559409/