1

我需要我的最终决定字段是 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;
4

2 回答 2

1

您需要将列别名放在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;
于 2011-07-29T13:43:14.380 回答
0

尝试使用 ISNULL 代替:

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;

于 2011-07-29T13:44:10.963 回答