开发者

Access IIF Query

开发者 https://www.devze.com 2023-03-24 00:28 出处:网络
I need my Final Decision field to be the result of the IIF statement. But I keep getting syntax errors.

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_DECI开发者_运维知识库SION] 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;


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;


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;

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号