访问IIF查询

发布于 2024-11-26 18:06:41 字数 526 浏览 1 评论 0原文

我需要将“最终决策”字段作为 IIF 语句的结果。

但我不断收到语法错误。

    SELECT x.AR_ID, 
           Final Decision: IIf([x].[R_DECISION] Is Not Null,
                               [R_DECISION],
                               IIf([ap_decsion] Is Not Null,
                                   [ap_decsion],
                                   IIf([ho_decision] Is Not Null,
                                       [ho_decision],[ar_decision])
                                   )
                              ) FROM x;

I need my Final Decision field to be the result of the IIF statement.

But I keep getting syntax errors.

    SELECT x.AR_ID, 
           Final Decision: IIf([x].[R_DECISION] Is Not Null,
                               [R_DECISION],
                               IIf([ap_decsion] Is Not Null,
                                   [ap_decsion],
                                   IIf([ho_decision] Is Not Null,
                                       [ho_decision],[ar_decision])
                                   )
                              ) FROM x;

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

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

发布评论

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

评论(2

泪眸﹌ 2024-12-03 18:06:41

您需要将列别名放在 IIF 语句的末尾,并在其周围放置 []

  SELECT x.AR_ID, 
         IIf([x].[R_DECISION] Is Not Null,
            [R_DECISION],
            IIf([ap_decsion] Is Not Null,
               [ap_decsion],
                  IIf([ho_decision] Is Not Null,
                     [ho_decision],
                     [ar_decision]))) as [Final Decision:]

  FROM x;

You need to put the column alias at the end of the IIF statement and put [] around it

  SELECT x.AR_ID, 
         IIf([x].[R_DECISION] Is Not Null,
            [R_DECISION],
            IIf([ap_decsion] Is Not Null,
               [ap_decsion],
                  IIf([ho_decision] Is Not Null,
                     [ho_decision],
                     [ar_decision]))) as [Final Decision:]

  FROM x;
痴情换悲伤 2024-12-03 18:06:41

尝试使用 ISNULL 代替:

SELECT x.AR_ID,最终决策:IIf(NOT ISNULL([x].[R_DECISION]),[R_DECISION],IIf(NOT ISNULL([ap_decsion]),[ap_decsion],IIf( NOT ISNULL([ho_decision]),[ho_decision],[ar_decision])))
来自 x;

Try using ISNULL instead:

SELECT x.AR_ID, Final Decision: IIf(NOT ISNULL([x].[R_DECISION]),[R_DECISION],IIf(NOT ISNULL([ap_decsion]),[ap_decsion],IIf(NOT ISNULL([ho_decision]),[ho_decision],[ar_decision])))
FROM x;

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文