<?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>topic Problem with Left Outer Join in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-left-outer-join/m-p/12438689#M1998513</link>
    <description>&lt;P&gt;Dear all,&lt;/P&gt;
  &lt;P&gt;I found a lot question about the LEFT OUTER JOIN but allow me to add 1 more to make it more precise and if there is any other solution with open SQL&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;SELECT
    FROM but000 INNER JOIN kna1
        ON but000~partner = kna1~kunnr
      LEFT OUTER JOIN but0is AS doy
        ON but000~partner = doy~partner
      LEFT OUTER JOIN tb038b AS doy_description
        ON doy~istype = doy_description~istype AND
           doy~istype = '0001' AND
           doy~ind_sector = doy_description~ind_sector AND
           doy_description~spras = 'G'
      LEFT OUTER JOIN but0is AS bus_type
        ON OUTER but000~partner = bus_type~partner
      LEFT JOIN tb038b AS bus_type_descr
        ON bus_type~istype = bus_type_descr~istype AND
           bus_type~istype = '0003' AND
           bus_type~ind_sector = bus_type_descr~ind_sector AND
           bus_type_descr~spras = 'G'
    FIELDS but000~partner, but000~bu_group AS partner_group, kna1~name1 AS name, kna1~name2 AS surname,
           kna1~name3 AS father_name, kna1~name4 AS mother_name, kna1~stceg AS vat, kna1~stcd1 AS police_id,
           kna1~stras AS address, kna1~pstlz AS post_code, kna1~ort01 AS city,
           bus_type_descr~ind_sector AS bus_type,
           bus_type_descr~text AS bus_type_descr,
           doy_description~ind_sector AS doy,
           doy_description~text AS doy_dercr
    WHERE but000~partner = @partner
&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;This one does not work even with 1 pair of LEFTs&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;SELECT
    FROM but000 INNER JOIN kna1
        ON but000~partner = kna1~kunnr
      LEFT OUTER JOIN but0is AS doy
        ON but000~partner = doy~partner
      LEFT OUTER JOIN tb038b AS doy_description
        ON doy~istype = doy_description~istype AND
           doy~istype = '0001' AND
           doy~ind_sector = doy_description~ind_sector AND
           doy_description~spras = 'G'

FIELDS but000~partner, but000~bu_group AS partner_group, kna1~name1 AS name, kna1~name2 AS surname,
           kna1~name3 AS father_name, kna1~name4 AS mother_name, kna1~stceg AS vat, kna1~stcd1 AS police_id,
           kna1~stras AS address, kna1~pstlz AS post_code, kna1~ort01 AS city,
           doy_description~ind_sector AS doy,
           doy_description~text AS doy_dercr
    WHERE but000~partner = @partner&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;I found the below answer&lt;/P&gt;
  &lt;P&gt;the left outer join can only from same table, E.G. &lt;/P&gt;
  &lt;P&gt; left outer join B to A &lt;/P&gt;
  &lt;P&gt;left outer join C to A &lt;/P&gt;
  &lt;P&gt;but can't &lt;/P&gt;
  &lt;P&gt;left outer join A to B &lt;/P&gt;
  &lt;P&gt;left outer join B to C&lt;/P&gt;
  &lt;P&gt;Are they correct and if yes how can do the above in a SQL query. &lt;/P&gt;
  &lt;P&gt;Thanks &lt;/P&gt;
  &lt;P&gt;Elias&lt;/P&gt;</description>
    <pubDate>Fri, 24 Sep 2021 09:02:28 GMT</pubDate>
    <dc:creator>ekekakos</dc:creator>
    <dc:date>2021-09-24T09:02:28Z</dc:date>
    <item>
      <title>Problem with Left Outer Join</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-left-outer-join/m-p/12438689#M1998513</link>
      <description>&lt;P&gt;Dear all,&lt;/P&gt;
  &lt;P&gt;I found a lot question about the LEFT OUTER JOIN but allow me to add 1 more to make it more precise and if there is any other solution with open SQL&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;SELECT
    FROM but000 INNER JOIN kna1
        ON but000~partner = kna1~kunnr
      LEFT OUTER JOIN but0is AS doy
        ON but000~partner = doy~partner
      LEFT OUTER JOIN tb038b AS doy_description
        ON doy~istype = doy_description~istype AND
           doy~istype = '0001' AND
           doy~ind_sector = doy_description~ind_sector AND
           doy_description~spras = 'G'
      LEFT OUTER JOIN but0is AS bus_type
        ON OUTER but000~partner = bus_type~partner
      LEFT JOIN tb038b AS bus_type_descr
        ON bus_type~istype = bus_type_descr~istype AND
           bus_type~istype = '0003' AND
           bus_type~ind_sector = bus_type_descr~ind_sector AND
           bus_type_descr~spras = 'G'
    FIELDS but000~partner, but000~bu_group AS partner_group, kna1~name1 AS name, kna1~name2 AS surname,
           kna1~name3 AS father_name, kna1~name4 AS mother_name, kna1~stceg AS vat, kna1~stcd1 AS police_id,
           kna1~stras AS address, kna1~pstlz AS post_code, kna1~ort01 AS city,
           bus_type_descr~ind_sector AS bus_type,
           bus_type_descr~text AS bus_type_descr,
           doy_description~ind_sector AS doy,
           doy_description~text AS doy_dercr
    WHERE but000~partner = @partner
&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;This one does not work even with 1 pair of LEFTs&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;SELECT
    FROM but000 INNER JOIN kna1
        ON but000~partner = kna1~kunnr
      LEFT OUTER JOIN but0is AS doy
        ON but000~partner = doy~partner
      LEFT OUTER JOIN tb038b AS doy_description
        ON doy~istype = doy_description~istype AND
           doy~istype = '0001' AND
           doy~ind_sector = doy_description~ind_sector AND
           doy_description~spras = 'G'

FIELDS but000~partner, but000~bu_group AS partner_group, kna1~name1 AS name, kna1~name2 AS surname,
           kna1~name3 AS father_name, kna1~name4 AS mother_name, kna1~stceg AS vat, kna1~stcd1 AS police_id,
           kna1~stras AS address, kna1~pstlz AS post_code, kna1~ort01 AS city,
           doy_description~ind_sector AS doy,
           doy_description~text AS doy_dercr
    WHERE but000~partner = @partner&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;I found the below answer&lt;/P&gt;
  &lt;P&gt;the left outer join can only from same table, E.G. &lt;/P&gt;
  &lt;P&gt; left outer join B to A &lt;/P&gt;
  &lt;P&gt;left outer join C to A &lt;/P&gt;
  &lt;P&gt;but can't &lt;/P&gt;
  &lt;P&gt;left outer join A to B &lt;/P&gt;
  &lt;P&gt;left outer join B to C&lt;/P&gt;
  &lt;P&gt;Are they correct and if yes how can do the above in a SQL query. &lt;/P&gt;
  &lt;P&gt;Thanks &lt;/P&gt;
  &lt;P&gt;Elias&lt;/P&gt;</description>
      <pubDate>Fri, 24 Sep 2021 09:02:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-left-outer-join/m-p/12438689#M1998513</guid>
      <dc:creator>ekekakos</dc:creator>
      <dc:date>2021-09-24T09:02:28Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with Left Outer Join</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-left-outer-join/m-p/12438690#M1998514</link>
      <description>&lt;P&gt;Finally the SQL query is not totally correct. The correct one is:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;    SELECT
    FROM but000 INNER JOIN kna1
        ON but000~partner = kna1~kunnr
      LEFT OUTER JOIN but0is AS doy
        ON doy~partner = but000~partner AND
           doy~istype = '0001'                         " This is the change
      LEFT OUTER JOIN tb038b AS doy_description
        ON doy~istype = doy_description~istype AND
           doy~ind_sector = doy_description~ind_sector AND
           doy_description~spras = 'G'
      LEFT OUTER JOIN but0is AS bus_type
        ON but000~partner = bus_type~partner AND
           bus_type~istype = '0003'                    " This is the change
      LEFT OUTER JOIN tb038b AS bus_type_descr
        ON bus_type~istype = bus_type_descr~istype AND
           bus_type~ind_sector = bus_type_descr~ind_sector AND
           bus_type_descr~spras = 'G'
    FIELDS DISTINCT but000~partner, but000~bu_group AS partner_group, kna1~name1 AS name, kna1~name2 AS surname,
           kna1~name3 AS father_name, kna1~name4 AS mother_name, kna1~stceg AS vat, kna1~stcd1 AS police_id,
           kna1~stras AS address, kna1~pstlz AS post_code, kna1~ort01 AS city,
           bus_type~ind_sector AS business_type ,
           bus_type_descr~text AS business_type_descr,
           doy~ind_sector AS doy,
           doy_description~text AS doy_description
    WHERE (where_clause)
    INTO TABLE @get_business_partners-bu_partners&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Elias&lt;/P&gt;</description>
      <pubDate>Fri, 24 Sep 2021 09:45:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-left-outer-join/m-p/12438690#M1998514</guid>
      <dc:creator>ekekakos</dc:creator>
      <dc:date>2021-09-24T09:45:00Z</dc:date>
    </item>
  </channel>
</rss>

