这个怎么优化啊。。
select * from 
(select 客户ID,点击消费,date from datasource where date>getdate()-32)a 
pivot(max(点击消费) for date in([2012-9-12],[2012-9-13]))b
left join 
(select 客户ID,avg(hittime) as hittime from downaccount
where date >=getdate()-32
group by 客户ID)c on b.客户ID=c.客户ID
left join
(select 客户ID,case when sum(点击次数)=0 then 0 else sum(点击消费)/sum(点击次数) end as acp
from datasource st where st.date >=getdate()-32
group by 客户ID)d on b.客户ID=d.客户ID