【问题标题】:CASE statement to IIF statementCASE 语句到 IIF 语句
【发布时间】:2018-09-05 00:10:17
【问题描述】:

我有这个需要在 Access 中转换为 IIF 的 CASE 语句:

Case When sfrstcr_pidm is not null Then 'A' WHen sfrstcr_pidm <> '' Then 'A' Else Null End as StudentStatus,

这是转换为 IIF 的正确方法吗?

IIF ([sfrstcr_pidm] is not null, ‘A’, IIF([sfrstcr_pidm] <> ‘’, ‘A’, Null))

【问题讨论】:

  • 你可以使用OR而不是嵌套语句?

标签: ms-access-2010 case iif-function


【解决方案1】:

将Case 语句转换为Access SQL 最明显的方法是使用Switch 函数。这需要多个参数,并使用 if ... then ... elseif ... 逻辑。它没有else 选项,但elseif true 可以解决这个问题。

使用这个函数,你的代码会变成下面这样:

Switch(sfrstcr_pidm is not null, 'A', sfrstcr_pidm <> '', 'A', True, Null)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-23
    • 1970-01-01
    • 2018-12-25
    • 2023-04-07
    相关资源
    最近更新 更多