求助一条查询语句
有这样一张表:   
       姓名            日期                                 销售金额 
       张三         2007-8-20                           800 
       张三         2007-8-25                           100 
       李四         2007-8-22                           1200 
       张三         2007-9-20                           650 
       李四         2007-9-25                           970        
 现在要做一条查询,把这个表格变成:   
          姓名      8月份         9月份 
          张三      900               650 
          李四      1200            970   
 应该怎样做啊?
------解决方案--------------------drop table tbtest 
 go 
 create table tbtest(姓名 varchar(10),日期 datetime,销售金额 int) 
 insert into tbtest 
 select  '张三 ', '2007-8-20 ',800 
 union all select  '张三 ', '2007-8-25 ',100 
 union all select  '李四 ', '2007-8-22 ',1200 
 union all select  '张三 ', '2007-9-20 ',650 
 union all select  '李四 ', '2007-9-25 ',970   
 declare @sql varchar(8000) 
 set @sql= ' ' 
 select @sql=@sql+ ',sum(case when convert(char(7),日期,120)= ' ' '+日期+ ' ' ' then 销售金额 else 0 end) as  ' ' '+日期+ ' ' ' ' 
 from (select distinct convert(char(7),日期,120) 日期 from tbtest)t 
 order by 日期 
 exec( 'select 姓名 '+@sql+ ' from tbtest group by 姓名 ') 
 /* 
 姓名         2007-08     2007-09      
 ---------- ----------- -----------  
 李四         1200        970 
 张三
------解决方案--------------------...为了星星..又要叉表一次了 
 select  姓名, 
 sum(case when month(日期)=8 then 销售金额 else 0 end) [8月份], 
 sum(case when month(日期)=9 then 销售金额 else 0 end) [9月份] 
 from  表 
 group by 姓名