cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

SAP HANA SQL Script where null = null not work.

0 Likes
2,586

Hi expert,

[1]

select tab1."BUKRS", tab1."AMT", tab2."AMT" from tab1 left join tab2

on tab1."BUKRS" = tab2."BUKRS";

The result is 1000 300 5000.

[2]

But, if field "ACCT", which is NULL, is added to where condition, e.g,

select tab1."BUKRS", tab1."AMT", tab2."AMT" from tab1 left join tab2

on tab1."BUKRS" = tab2."BUKRS" and tab1."ACCT" = tab2."ACCT";


The result is 1000 300 NULL.

The value of tab2."AMT"(5000) is not fetched.

[3]

So , my question is:

Fields which are NULL, can not be used in where condition ?

Tks.

View Entire Topic
eason_chen
Product and Topic Expert
Product and Topic Expert
0 Likes

Hi,

I consider it should be normal as null = null is not a valid expression.
Alternatively, you may modify your query as following if you want it to be shown in result when both of them are null.
select tab1."BUKRS", tab1."AMT", tab2."AMT" from tab1 left join tab2 on tab1."BUKRS" = tab2."BUKRS" and (tab1."ACCT" = tab2."ACCT" or (tab1."ACCT" IS NULL and tab2."ACCT" is NULL));


Best Regards,
Eason Chen

0 Likes

thanks a lot .