|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
回复 13楼 燃烧的地板 的帖子
在代码中将所有的空值以零替换,最终版本为 :
- select
- "总计" as 客户名称,
- "总计" as 日期,
- "总计" as 摘要,
- (select sum(iif(isnull(应收款),0,应收款)) as 应收款 from [Sheet1$a1:e11]) as 应收款,
- (select sum(iif(isnull(已收款),0,已收款)) as 已收款 from [Sheet1$a1:e11]) as 已收款,
- (select sum(iif(isnull(应收款),0,应收款))-sum(iif(isnull(已收款),0,已收款)) as 未收款 from [Sheet1$a1:e11]) as 未收款 from
- [Sheet1$a1:e11]
- union
- select
- a.客户名称,
- a.日期,
- a.摘要,
- a.应收款,
- a.已收款,
- (
- select
- sum(iif(isnull(应收款),0,应收款))-sum(iif(isnull(已收款),0,已收款)) as 未收款
- from
- [Sheet1$a1:e11]b
- where
- a.客户名称=b.客户名称
- and
- a.日期>=b.日期
- ) as 未收款
- from
- [Sheet1$a1:e11]a
复制代码
[ 本帖最后由 masterexcel 于 2010-1-9 19:13 编辑 ] |
|