on ‎2023 Jan 03 3:15 AM
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.
Request clarification before answering.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 15 | |
| 9 | |
| 6 | |
| 4 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.