[code=SQL]
select 客户名称,sum(销售额) as 月销售额, month(销售日期) as 月 into #table1 from table group by left(日期,7),客户名称
select 客户名称,
max(case when 月='1' then 月销售额 else 0 end) 1月,
max(case when 月='2' then 月销售额 else 0 end) 2月,
max(case when 月='3' then 月销售额 else 0 end) 3月,
。。。。。。。。。。
sum(case when 月='12' then 月销售额 else 0 end) 12月,
from #table1
group by 客户名称