【问题标题】:Netsuite CASE WHEN expression in custom search is returning "invalid expression"Netsuite CASE WHEN 自定义搜索中的表达式返回“无效表达式”
【发布时间】:2013-08-08 21:54:15
【问题描述】:

我是在 NetSuite 中编写 CASE 表达式的新手。我在自定义搜索的公式字段中插入了以下表达式。

CASE WHEN {item.custitem_custid}=05 OR {item.custitem_custid}=12 THEN
     ({item.custitem_margin}/2) 
ELSE 
     ({item.custitem_margin}/3)
END

并因此得到“无效的表达式。如果 WHEN 情况为真,我试图将边距字段值除以 2,如果不正确,则除以 3。有人知道我的公式有什么问题吗?

【问题讨论】:

  • 你的语法对我来说看起来不错。您在搜索什么记录类型?我的想法是加入工作不正常。附带说明一下,在公式中使用除法时,NetSuite 建议您使用 X / nullif(Y, 0) 而不是仅使用 X / Y 以避免被零除。
  • 谢谢。我试试看。

标签: sql netsuite


【解决方案1】:

我觉得你需要加括号:

CASE WHEN ({item.custitem_custid}=05 OR {item.custitem_custid}=12) THEN
     ({item.custitem_margin}/2) 
ELSE 
     ({item.custitem_margin}/3)
END

【讨论】:

【解决方案2】:

我同意 egrubaugh360 的观点,即语法很好,并且连接可能无法正常工作。在您的论坛中,只需仔细检查“项目”。部分,看看你能做什么。

我也同意 NVL() 的建议,但我也可以看到您的分母分别是 2 和 3,因此 NVL() 函数不会有任何帮助。请务必在您的分母是未知值时使用 NVL(),例如来自您的记录/交易中的字段。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-02-01
    • 2012-09-20
    • 1970-01-01
    • 2021-03-26
    • 2018-04-04
    • 1970-01-01
    • 1970-01-01
    • 2014-09-17
    相关资源
    最近更新 更多