คำตอบ :
select hn, sum(Octo) as 'ต.ค.', sum(Nov) as 'พ.ย.', sum(Dece) as 'ธ.ค.', sum(Jan) as 'ม.ค.', sum(Feb) as 'ก.พ.', sum(Mar) as 'มี.ค.', sum(Apr) as 'เม.ย.', sum(May) as 'พ.ค.', sum(Jun) as 'มิ.ย.', sum(Jul) as 'ก.ค.', sum(Aug) as 'ส.ค.',sum(Sep) as 'ก.ย.' from (
select hn,
if(month(vstdate)=10,fbs,'') as Octo,
if(month(vstdate)=11,fbs,'') as Nov,
if(month(vstdate)=12,fbs,'') as Dece,
if(month(vstdate)=1,fbs,'') as Jan,
if(month(vstdate)=2,fbs,'') as Feb,
if(month(vstdate)=3,fbs,'') as Mar,
if(month(vstdate)=4,fbs,'') as Apr,
if(month(vstdate)=5,fbs,'') as May,
if(month(vstdate)=6,fbs,'') as Jun,
if(month(vstdate)=7,fbs,'') as Jul,
if(month(vstdate)=8,fbs,'') as Aug,
if(month(vstdate)=9,fbs,'') as Sep
from opdscreen
where vstdate between "2012-10-01" and "2013-09-30" and fbs > 0
group by hn, month(vstdate)
) as t
group by hn