declare @s varchar(8000)
set @s = ''
select @s = @s +',[month'+cast(month as varchar(2))+']= case month when '+month+' then amount else 0 end' from (select  month  from table group by  month  ) aexec('select mtlid '+@s+' from table group by mtlid ')