如何在ms access sql查询中使用嵌套IIF语句
我的项目使用的是MS Access 2010数据库,我想在MS Access SQL查询中使用嵌套的IIF语句。但是我在sqb查询语句中得到了查询表达式中的语法错误。 下面我提到了示例代码-如何在ms access sql查询中使用嵌套IIF语句,sql,ms-access-2010,Sql,Ms Access 2010,我的项目使用的是MS Access 2010数据库,我想在MS Access SQL查询中使用嵌套的IIF语句。但是我在sqb查询语句中得到了查询表达式中的语法错误。 下面我提到了示例代码- IIF(SimpleLoan=0,0,transDemand.SimpleInstallment,IIF(transDemand.SimpleInstallment=0,select Installment from LoanMaster where FYear=(select max(FYear) fro
IIF(SimpleLoan=0,0,transDemand.SimpleInstallment,IIF(transDemand.SimpleInstallment=0,select Installment from LoanMaster where FYear=(select max(FYear) from LoanMaster),0)) AS SimpleInstallment
因此,请建议我如何解决它?语法错误是外部IIF有4个参数,而不是3个,请在此处检查它们:
IIF(
SimpleLoan=0,
0,
transDemand.SimpleInstallment,
IIF(
transDemand.SimpleInstallment=0,
select Installment from LoanMaster where FYear=(select max(FYear) from LoanMaster),
0
)
) AS SimpleInstallment
看到这个了吗
对于IIF,语法为:
IIf(expr , truepart , falsepart)
请提供示例数据、期望结果以及您尝试执行的操作的解释。你的查询没有意义,先生,这是我试图执行的全部查询。但它仍然显示了子查询的错误。这是示例查询-选择Customer.AccNumber2,Customer.Name,IIFtransDemand.SimpleLoan>=0,IIFtransDemand.SimpleInstallation=0,从LoanMaster选择分期付款,其中FYear=从LoanMaster选择maxFYear,0作为SimpleInstallation,从Customer.AccNumber=transDemand.AccNumber上的Customer内部联接transDemand,其中DemandDate=从transDemand中选择maxDemandDate;我修改了查询,但子查询仍然出现错误。修改后的查询-IIFSimpleLoan>=0,IIFtransDemand.SimpleInstallment=0,从LoanMaster选择分期付款,其中FYear=select maxFYear from LoanMaster,0作为SimpleInstallmentNow您在外部IIF中有2个参数,而不是3个。