<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Question Re: SAP HANA SQL Script where null = null not work. in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/sap-hana-sql-script-where-null-null-not-work/qaa-p/12712286#M4770401</link>
    <description>&lt;P&gt;thanks a lot .&lt;/P&gt;</description>
    <pubDate>Wed, 04 Jan 2023 07:08:50 GMT</pubDate>
    <dc:creator>former_member822625</dc:creator>
    <dc:date>2023-01-04T07:08:50Z</dc:date>
    <item>
      <title>SAP HANA SQL Script where null = null not work.</title>
      <link>https://community.sap.com/t5/technology-q-a/sap-hana-sql-script-where-null-null-not-work/qaq-p/12712283</link>
      <description>&lt;P&gt;Hi expert,&lt;/P&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/2122025-image.png" /&gt;&lt;/P&gt;
  &lt;P&gt;[1]&lt;/P&gt;
  &lt;P&gt;select tab1."BUKRS", tab1."AMT", tab2."AMT" from tab1 left join tab2 &lt;/P&gt;
  &lt;P&gt;on tab1."BUKRS" = tab2."BUKRS";&lt;/P&gt;
  &lt;P&gt;The result is 1000 300 5000.&lt;/P&gt;
  &lt;P&gt;[2] &lt;/P&gt;
  &lt;P&gt;But, if field "ACCT", which is &lt;STRONG&gt;NULL&lt;/STRONG&gt;, is added to where condition, e.g,&lt;/P&gt;
  &lt;P&gt;select tab1."BUKRS", tab1."AMT", tab2."AMT" from tab1 left join tab2 &lt;/P&gt;
  &lt;P&gt;on tab1."BUKRS" = tab2."BUKRS" &lt;STRONG&gt;&lt;EM&gt;and &lt;/EM&gt;&lt;/STRONG&gt;&lt;STRONG&gt;&lt;EM&gt;tab1."ACCT" = tab2."ACCT&lt;/EM&gt;&lt;/STRONG&gt;&lt;STRONG&gt;&lt;EM&gt;";&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;
  &lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;
  &lt;P&gt;The result is 1000 300 &lt;STRONG&gt;NULL&lt;/STRONG&gt;. &lt;/P&gt;
  &lt;P&gt;The value of tab2."AMT"(5000) is not fetched.&lt;/P&gt;
  &lt;P&gt;[3]&lt;/P&gt;
  &lt;P&gt;So , my question is:&lt;/P&gt;
  &lt;P&gt;Fields which are &lt;STRONG&gt;NULL&lt;/STRONG&gt;, can not be used in where condition ?&lt;/P&gt;
  &lt;P&gt;Tks.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Jan 2023 03:15:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sap-hana-sql-script-where-null-null-not-work/qaq-p/12712283</guid>
      <dc:creator>former_member822625</dc:creator>
      <dc:date>2023-01-03T03:15:02Z</dc:date>
    </item>
    <item>
      <title>Re: SAP HANA SQL Script where null = null not work.</title>
      <link>https://community.sap.com/t5/technology-q-a/sap-hana-sql-script-where-null-null-not-work/qaa-p/12712284#M4770399</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;I consider it should be normal as null = null is not a valid expression.&lt;BR /&gt;Alternatively, you may modify your query as following if you want it to be shown in result when both of them are null.&lt;BR /&gt;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));&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Best Regards,&lt;BR /&gt;Eason Chen&lt;/P&gt;</description>
      <pubDate>Tue, 03 Jan 2023 07:11:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sap-hana-sql-script-where-null-null-not-work/qaa-p/12712284#M4770399</guid>
      <dc:creator>eason_chen</dc:creator>
      <dc:date>2023-01-03T07:11:34Z</dc:date>
    </item>
    <item>
      <title>Re: SAP HANA SQL Script where null = null not work.</title>
      <link>https://community.sap.com/t5/technology-q-a/sap-hana-sql-script-where-null-null-not-work/qaa-p/12712285#M4770400</link>
      <description>&lt;P&gt;Hi Wei, &lt;/P&gt;&lt;P&gt;every comparison with &lt;STRONG&gt;NULL &lt;/STRONG&gt;results always in the logical value &lt;STRONG&gt;UNKNOWN&lt;/STRONG&gt;. But in &lt;STRONG&gt;JOIN &lt;/STRONG&gt;as well as in &lt;STRONG&gt;WHERE&lt;/STRONG&gt; conditions, you need the logical value &lt;STRONG&gt;TRUE &lt;/STRONG&gt;so that a record is considered. &lt;/P&gt;&lt;P&gt;In a &lt;STRONG&gt;WHERE &lt;/STRONG&gt;condition, the &lt;STRONG&gt;IS NULL&lt;/STRONG&gt; predicate is useful. Be aware: &lt;STRONG&gt;x = NULL&lt;/STRONG&gt; is not working, because it is a comparison with &lt;STRONG&gt;NULL&lt;/STRONG&gt;. Use &lt;STRONG&gt;x IS NULL&lt;/STRONG&gt; instead. &lt;/P&gt;&lt;P&gt;In a &lt;STRONG&gt;JOIN &lt;/STRONG&gt;condition, you can map &lt;STRONG&gt;NULL &lt;/STRONG&gt;to a valid value (e.g. the empty string '') with the SQL-Function  &lt;STRONG&gt;IFNULL( )&lt;/STRONG&gt;:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;select tab1."BUKRS", 
       tab1."AMT", 
       tab2."AMT" 
  from tab1 
  left join tab2
    on tab1."BUKRS" = tab2."BUKRS" 
   and IFNULL(tab1."ACCT", '') = IFNULL(tab2."ACCT", '');&amp;lt;br&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;In this example, you have to be aware that the empty string could also be part of your data. In this case you have choose an other replacement value. &lt;/P&gt;&lt;P&gt;With best regards, &lt;/P&gt;&lt;P&gt;Jörg&lt;/P&gt;</description>
      <pubDate>Tue, 03 Jan 2023 08:00:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sap-hana-sql-script-where-null-null-not-work/qaa-p/12712285#M4770400</guid>
      <dc:creator>Jrg_Brandeis</dc:creator>
      <dc:date>2023-01-03T08:00:37Z</dc:date>
    </item>
    <item>
      <title>Re: SAP HANA SQL Script where null = null not work.</title>
      <link>https://community.sap.com/t5/technology-q-a/sap-hana-sql-script-where-null-null-not-work/qaa-p/12712286#M4770401</link>
      <description>&lt;P&gt;thanks a lot .&lt;/P&gt;</description>
      <pubDate>Wed, 04 Jan 2023 07:08:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sap-hana-sql-script-where-null-null-not-work/qaa-p/12712286#M4770401</guid>
      <dc:creator>former_member822625</dc:creator>
      <dc:date>2023-01-04T07:08:50Z</dc:date>
    </item>
  </channel>
</rss>

