使用 null MS Access 进行计算

发布于 2024-10-30 23:36:53 字数 396 浏览 0 评论 0原文

我的表名称是 MS ACess 中的 CAPCON 字段ae ID,Transaction, AMount,

我的查询是

Select distinct( CapCon.ID),
 (Select sum(amount) from CapCon as c 
    where c.id=CapCon.id 
    and transaction='Deposite') - 
 (Select sum(amount) from CapCon as c 
    where c.id=CapCon.id and transaction='Withdrawal') 
as [Capital Contribution] from CapCOn

如果没有提现交易,则对应ID的【出资】中没有输出

My Table name is CAPCON in MS ACess
Fields ae ID,Transaction, AMount,

My query is

Select distinct( CapCon.ID),
 (Select sum(amount) from CapCon as c 
    where c.id=CapCon.id 
    and transaction='Deposite') - 
 (Select sum(amount) from CapCon as c 
    where c.id=CapCon.id and transaction='Withdrawal') 
as [Capital Contribution] from CapCOn

IF the there is no withdrawal transaction, there is no output in [Capital Contribution] for the corresponding ID

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

差↓一点笑了 2024-11-06 23:36:53

您需要检查 where 子句中是否为 null:

Select distinct( CapCon.ID),
  (Select sum(amount) from CapCon as c 
     where c.id=CapCon.id 
     and transaction='Deposite') -
  (Select sum(amount) from CapCon as c 
     where c.id=CapCon.id 
     and transaction='Withdrawal' 
     and transaction is not null) 
as [Capital Contribution] from CapCOn

You need to check for null in your where clause:

Select distinct( CapCon.ID),
  (Select sum(amount) from CapCon as c 
     where c.id=CapCon.id 
     and transaction='Deposite') -
  (Select sum(amount) from CapCon as c 
     where c.id=CapCon.id 
     and transaction='Withdrawal' 
     and transaction is not null) 
as [Capital Contribution] from CapCOn
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文