【问题标题】:iif function Access - wrong resultiif 函数访问 - 结果错误
【发布时间】:2014-04-02 11:25:48
【问题描述】:

我正在从 VB.NET 应用程序启动查询 (Access 2003)。

select id, customer, date, total, iif ([amountGet] - [amountSent] = [total], 'Yes', 'No') as result from invoices

但是iif返回错误的结果

表格
编号:1
客户:佩佩
日期:2014 年 1 月 1 日
总计:1,8
数量获得:5
发送金额:3,2

结果:
返回“否”

什么时候应该返回“是”,因为 5-3,2=1,8

【问题讨论】:

  • amountGet、amountSent、total有哪些类型?这很可能是由于舍入错误造成的。
  • 双(自动小数)
  • 小数位使用, 而不是. 可能是您的区域设置有问题吗?您是否尝试在即时窗口中运行它?
  • 您好:按照 jpw 的 cmets,现在我将四舍五入到小数点后 2 位,看起来效果很好。 iif ( round([amountGet] - [amountSent],2) = round([total],2) )

标签: ms-access iif


【解决方案1】:

将数字四舍五入到相同的小数位数,在我的例子中是 2 个小数,返回正确的结果:

iif ( round([amountGet] - [amountSent],2) = round([total],2) )

@jpw 感谢您的评论,因为它帮助我找到了解决方案

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-30
    • 2013-11-30
    • 1970-01-01
    • 2018-11-11
    • 1970-01-01
    相关资源
    最近更新 更多