以文本方式查看主题 - Foxtable(狐表) (http://www.foxtable.com/bbs/index.asp) -- 专家坐堂 (http://www.foxtable.com/bbs/list.asp?boardid=2) ---- [求助]请老师改下之前帮我做的例子 (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=114373) |
-- 作者:huangfanzi -- 发布时间:2018/2/4 21:26:00 -- [求助]请老师改下之前帮我做的例子 计算账龄的例子,发现一个BUG,如果某家公司只有发货记录,没有收款记录,这家公司没有显示在查询表上,按理来说是应该显示的。 [此贴子已经被作者于2018/2/4 21:28:38编辑过]
|
-- 作者:有点甜 -- 发布时间:2018/2/4 22:49:00 -- where 发货金额-收款金额 > 0
改成
where 发货金额-iif(收款金额 is null,0,收款金额) > 0 |
-- 作者:huangfanzi -- 发布时间:2018/2/5 8:12:00 -- 改后还有个小BUG 没有收款记录的“C公司”,发货金额是有数值1000,但应收款处应该也是1000,现在的例子中这个应收款为空,另外,能不能实现所有为空的地方显示 0 呢? 请老师协助下,谢谢!
|
-- 作者:有点甜 -- 发布时间:2018/2/5 8:46:00 -- Dim rq As WinForm.DateTimePicker = e.Form.Controls("DateTimePicker1") Tables(e.Form.Name & "_Table1").Fill("Select 公司,发货金额,收款金额,发货金额-iif(收款金额 is null,0,收款金额) As 应收款,[1-30天],[31-60天],[61-90天],[91-180天],[181-360天],[360天以上] from (Select 公司,SUM(发货金额) As 发货金额,(Select sum(收款金额) from {收款} b where a.公司 = b.公司 ) As 收款金额,(Select sum(发货金额) from {发货} d where d.公司 = a.公司 And 发货日期 >= #" & rq.Value.AddDays(-31) & "# And 发货日期 < #" & rq.Value.AddDays(-1) & "# ) As [1-30天],(Select sum(发货金额) from {发货} d where d.公司 = a.公司 And 发货日期 >= #" & rq.Value.AddDays(-61) & "# And 发货日期 < #" & rq.Value.AddDays(-31) & "# ) As [31-60天],(Select sum(发货金额) from {发货} d where d.公司 = a.公司 And 发货日期 >= #" & rq.Value.AddDays(-91) & "# And 发货日期 < #" & rq.Value.AddDays(-61) & "# ) As [61-90天],(Select sum(发货金额) from {发货} d where d.公司 = a.公司 And 发货日期 >= #" & rq.Value.AddDays(-181) & "# And 发货日期 < #" & rq.Value.AddDays(-91) & "# ) As [91-180天],(Select sum(发货金额) from {发货} d where d.公司 = a.公司 And 发货日期 >= #" & rq.Value.AddDays(-361) & "# And 发货日期 < #" & rq.Value.AddDays(-181) & "# ) As [181-360天],(Select sum(发货金额) from {发货} d where d.公司 = a.公司 And 发货日期 < #" & rq.Value.AddDays(-361) & "# ) As [360天以上] from {发货} As a group by 公司) As c where 发货金额-iif(收款金额 is null,0,收款金额) > 0",True) |