任何人都可以建议以下IF语句的语法,
IIf
( Cur_Insert_Cost,
Cur_Insert_Cost/Cur_Insert_Edges,
Cur_Regrindable_Cost/(Cur_Regrinds_Possible+1)
) AS Cur_Cost_Edge_Regrind
以上行来自带有Ms-Access DB的Excel报告
我没有理解条件部分...... !!!
Cur_Insert_Cost,Cur_Insert_Edges,Cur_Regrindable_Cost ......等是列名
答案 0 :(得分:4)
IIF是三元运营商。它由逗号分隔的三个部分组成
iif(expression, truepart, falsepart)
在你的情况下,它意味着:
if Cur_Insert_Cost is not zero then
return the result of the expression Cur_Insert_Cost/Cur_Insert_Edges
else
return the result of the expression Cur_Regrindable_Cost/(Cur_Regrinds_Possible+1)
结果将在查询中命名为Cur_Cost_Edge_Regrind
答案 1 :(得分:0)
测试是否为Cur_Insert_Cost 对于false或者任何Access计为false都被视为空。
所以这可能意味着 Cur_Insert_Cost = NULL,0,'',false(我想我忘记了一些替代方案)
正如您所看到的,第一部分使用的是和IIRC 应用于NULL的Cur_Insert_Cost会给出一个例外(但这只是我的记忆)
答案 2 :(得分:0)
声明说列Cur_Cost_Edge_Regrind
的值是:
Cur_Insert_Cost/Cur_Insert_Edges
为真(或1)Cur_Insert_Cost
的结果
Cur_Regrindable_Cost/(Cur_Regrinds_Possible+1)
为FALSE(或0)Cur_Insert_Cost
的结果
希望有帮助...