日期:2014-05-17 浏览次数:20576 次
declare @sql varchar(8000)
select @sql=isnull(@sql+',','') +'sum(case when SFXM_SFXMMC='''+SFXM_SFXMMC+''' then SKJE else 0 end) as ['+SFXM_SFXMMC+']'
from (select distinct SFXM_SFXMMC from BB_RSFQDCZKJ_Second ) t
ORDER BY SFXM_SFXMMC
exec ('select FJDA_FJID 房间代码,FJDA_FJMC 房间名称,jkr AS 租户名称, SKR 收款人,FJDA_JZMJ 建筑面积,
tzrq 实收日期, fyqj 缴费期间,YS AS 缴费月数,skfs 收款方式 ,PZH 凭证号码,
SUM(SKJE) 合计,'+@sql+'into BB_RSFQDCZKJ_first from BB_RSFQDCZKJ_Second
group by FJDA_FJID ,FJDA_FJMC ,jkr,SKR,FJDA_JZMJ ,tzrq , fyqj ,YS ,skfs ,PZH')