select @sql = @sql + 'sum(case convert(char(6),A_date,112) when '''+[temp]+'''
then a_mnt else 0 end) as '''+[temp]+''','
from (select distinct convert(char(6),A_date,112) [temp] from 表A where year(A_date)=@你的年如2002) as a
select @sql = @sql + 'sum(case convert(char(6),A_date,112) when '''+[temp]+'''
then a_mnt else 0 end) as '''+[temp]+''','
from (select distinct convert(char(6),A_date,112) [temp] from 表A where year(A_date)=@你的年如2002) as a