|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Select sum(金额) FROM (Select 客户编码,sum(金额) as 金额 FROM (Select gl_accass.ccus_id as 客户编码,sum((case when gl_accass.cbegind_c<>N'贷' then gl_accass.mb else -gl_accass.mb end )) as 金额 FROM code INNER JOIN gl_accass ON code.ccode = gl_accass.ccode WHERE gl_accass.iperiod=1 and gl_accass.ccode like N'1133%' and gl_accass.ccus_id is not null Group by gl_accass.ccus_id order by gl_accass.ccus_id union Select GL_accvouch.ccus_id as 客户编码,sum(GL_accvouch.md-GL_accvouch.mc) as 金额 FROM code INNER JOIN gl_accvouch ON code.ccode = gl_accvouch.ccode WHERE GL_accvouch.iflag is null and iperiod<>0 and iperiod<13 and GL_accvouch.ccode like N'1133%' and dbill_date<=N'2008-12-31' and GL_accvouch.ccus_id is not null Group by GL_accvouch.ccus_id order by GL_accvouch.ccus_id) group by 客户编码) where 金额<0 |
|