Access IIF Query
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;
精彩评论