访问IIF查询
我需要将“最终决策”字段作为 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要将列别名放在
IIF
语句的末尾,并在其周围放置[]
You need to put the column alias at the end of the
IIF
statement and put[]
around it尝试使用 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;