【问题标题】:Where is the error in this? ( access query)这其中的错误在哪里? (访问查询)
【发布时间】:2017-06-08 14:21:16
【问题描述】:
SELECT [02d1_NTS_Report_Structure].Nation, [02d1_NTS_Report_Structure].Region, 
    [02d1_NTS_Report_Structure].Territory, [02d1_NTS_Report_Structure].Zone,
    iif ([02d1_NTS_Report_Structure].Zone="-", 
        iff ([02d1_NTS_Report_Structure].Territory="-",
            iff ([02d1_NTS_Report_Structure].Region="-", 
                [02d1_NTS_Report_Structure].Nation, 
                [02d1_NTS_Report_Structure].Region),
        [02d1_NTS_Report_Structure].Territory), 
    [02d1_NTS_Report_Structure].Zone)
FROM 02d1_NTS_Report_Structure;

【问题讨论】:

  • 哪个错误?您是否收到任何错误代码/消息?还是“错误”的结果?
  • 你告诉我们错误在哪里!
  • 是的,我收到一条错误声明。表达式中未定义的函数 iff

标签: sql ms-access


【解决方案1】:

您似乎在几个地方使用了“IFF”而不是“IIF”。

试试这个:

SELECT [02d1_NTS_Report_Structure].Nation, [02d1_NTS_Report_Structure].Region, 
    [02d1_NTS_Report_Structure].Territory, [02d1_NTS_Report_Structure].Zone,
    iif ([02d1_NTS_Report_Structure].Zone="-", 
        iif ([02d1_NTS_Report_Structure].Territory="-",
            iif ([02d1_NTS_Report_Structure].Region="-", 
                [02d1_NTS_Report_Structure].Nation, 
                [02d1_NTS_Report_Structure].Region),
        [02d1_NTS_Report_Structure].Territory), 
    [02d1_NTS_Report_Structure].Zone)
FROM 02d1_NTS_Report_Structure;

【讨论】:

    【解决方案2】:

    我唯一能看到的是你可能应该在你的表名周围加上括号:

    SELECT [02d1_NTS_Report_Structure].Nation, 
    [02d1_NTS_Report_Structure].Region, 
    [02d1_NTS_Report_Structure].Territory, 
    [02d1_NTS_Report_Structure].Zone, 
    IIF([02d1_NTS_Report_Structure].Zone="-", 
        IIF([02d1_NTS_Report_Structure].Territory="-",
           IIF([02d1_NTS_Report_Structure].Region="-", 
               [02d1_NTS_Report_Structure].Nation,
               [02d1_NTS_Report_Structure].Region),
            [02d1_NTS_Report_Structure].Territory), 
         [02d1_NTS_Report_Structure].Zone) 
        FROM [02d1_NTS_Report_Structure];
    

    【讨论】:

    • 为了记录,在他的整个 SQL 字符串中的任何地方都不需要括号。仅当您的表或字段名称包含空格时才需要括号。
    • 很高兴知道。我完全错过了 IIF 和 IFF 之间的切换 :)
    猜你喜欢
    • 2021-03-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-17
    • 2014-01-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多