[英]SQL "IS NOT NULL" compensation for SAP HANA SQLScript
Actually I tried to run a is null
SQL Statement on a SAP HANA Database using the SAP HANA Studio.实际上,我尝试使用 SAP HANA Studio 在 SAP HANA 数据库上运行is null
SQL 语句。 This does not work because SQLScript has no is not null
or is null
function.这不起作用,因为 SQLScript 没有is not null
或is null
函数。 My statement looks like:我的声明看起来像:
Select *
From MSEG
Where KDAUF is null
Unfortunately it does not work.不幸的是它不起作用。 Does anybody know an alternative approach which is practicable using SAP HANA SQLScript?有人知道使用 SAP HANA SQLScript 可行的替代方法吗? On the internet I found a hint to either use NULLIF
or COALESCE
.在互联网上,我找到了使用NULLIF
或COALESCE
的提示。 But I neither know how to use this function nor to adapt it to a working WHERE
condition.但我既不知道如何使用这个函数,也不知道如何让它适应工作的WHERE
条件。
NULLIF ( expression , expression ) Returns the same type as the first expression. NULLIF ( expression , expression ) 返回与第一个表达式相同的类型。
NULLIF returns the first expression if the two expressions are not equal.如果两个表达式不相等,则 NULLIF 返回第一个表达式。 If the expressions are equal, NULLIF returns a null value of the type of the first expression WHERE IFNULL(KDAUF , comparison value) I never use this one如果表达式相等,则 NULLIF 返回第一个表达式类型的空值 WHERE IFNULL(KDAUF , compare value) 我从不使用这个
The other is coalesce where if the first vaLue is null, the second VALUE is returned:另一个是合并,如果第一个值为空,则返回第二个 VALUE:
WHERE VALUEa = COALESCE(KDAUF,valuea) WHERE VALUEa = COALESCE(KDAUF,valuea)
here, if kdaUf Is null, coalesce will will return valuea, the default if the first value is null.这里,如果 kdaUf 为 null,则合并将返回 valuea,如果第一个值为 null,则为默认值。 Since valuea = valuea, the where clause will be true, which is just another way of validating that KDAUF IS NULL由于 valuea = valuea,where 子句将为真,这只是验证 KDAUF IS NULL 的另一种方式
尝试以这种方式使用它
Select * from MSEG Where KDAUF **NE** ''
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.