<?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 SQL-Join with priority select in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-join-with-priority-select/m-p/12490080#M2002440</link>
    <description>&lt;PRE&gt;&lt;CODE&gt;Dear All&lt;BR /&gt;Is there a possibilty to select data with SQL-Joins in a priority way?&lt;BR /&gt;For example there are some material description stored in a MAKT and I want to select one description.&lt;BR /&gt;At first the description in 'DE' if available, or  description in 'EN' if available, else any other (only 1)&lt;BR /&gt;&lt;BR /&gt;Example (given data)&lt;BR /&gt;MAKT-MATNR  MAKT-SPRAS  MAKT-MAKTX&lt;BR /&gt;2001        DE          Beschreibung für 2001&lt;BR /&gt;2001        EN          Description for 2001&lt;BR /&gt;2001        FR          Descriptif pour 2001&lt;BR /&gt;2002        EN          Description for 2002&lt;BR /&gt;2002        FR          Descriptif pour 2003&lt;BR /&gt;2003        BG          Описание за 2004г&lt;BR /&gt;2003        FR          Descriptif pour 2004&lt;BR /&gt;2003        IT          Descrizione per il 2001&lt;BR /&gt;&lt;BR /&gt;SELECT FROM marc  &lt;BR /&gt;INNER JOIN makt&lt;BR /&gt;  ON marc~matnr = makt~matnr&lt;BR /&gt;  AND spras = ?&lt;BR /&gt;  FIELDS&lt;BR /&gt;    marc~matnr,&lt;BR /&gt;    marc~werks,&lt;BR /&gt;    marc~dispo,&lt;BR /&gt;    makt~spras,&lt;BR /&gt;    makt~maktx&lt;BR /&gt;  WHERE marc~matnr BETWEEN `000000000000002001` AND `000000000000002003`&lt;BR /&gt;    AND marc~werks = '0002'&amp;lt;br&amp;gt;  INTO TABLE @DATA(lt_mat).&lt;BR /&gt;

Desired results:

2001  0002  D01  DE  Beschreibung für 2001&lt;BR /&gt;2002  0002  D01  EN  Description for 2002&lt;BR /&gt;2003  0002  D01  BG  Описание за 2004г&lt;/CODE&gt;&lt;/PRE&gt; 
  &lt;PRE&gt;&lt;CODE&gt;Any idea to solve it?&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 08 Apr 2022 13:55:08 GMT</pubDate>
    <dc:creator>jrgen_bauer</dc:creator>
    <dc:date>2022-04-08T13:55:08Z</dc:date>
    <item>
      <title>SQL-Join with priority select</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-join-with-priority-select/m-p/12490080#M2002440</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;Dear All&lt;BR /&gt;Is there a possibilty to select data with SQL-Joins in a priority way?&lt;BR /&gt;For example there are some material description stored in a MAKT and I want to select one description.&lt;BR /&gt;At first the description in 'DE' if available, or  description in 'EN' if available, else any other (only 1)&lt;BR /&gt;&lt;BR /&gt;Example (given data)&lt;BR /&gt;MAKT-MATNR  MAKT-SPRAS  MAKT-MAKTX&lt;BR /&gt;2001        DE          Beschreibung für 2001&lt;BR /&gt;2001        EN          Description for 2001&lt;BR /&gt;2001        FR          Descriptif pour 2001&lt;BR /&gt;2002        EN          Description for 2002&lt;BR /&gt;2002        FR          Descriptif pour 2003&lt;BR /&gt;2003        BG          Описание за 2004г&lt;BR /&gt;2003        FR          Descriptif pour 2004&lt;BR /&gt;2003        IT          Descrizione per il 2001&lt;BR /&gt;&lt;BR /&gt;SELECT FROM marc  &lt;BR /&gt;INNER JOIN makt&lt;BR /&gt;  ON marc~matnr = makt~matnr&lt;BR /&gt;  AND spras = ?&lt;BR /&gt;  FIELDS&lt;BR /&gt;    marc~matnr,&lt;BR /&gt;    marc~werks,&lt;BR /&gt;    marc~dispo,&lt;BR /&gt;    makt~spras,&lt;BR /&gt;    makt~maktx&lt;BR /&gt;  WHERE marc~matnr BETWEEN `000000000000002001` AND `000000000000002003`&lt;BR /&gt;    AND marc~werks = '0002'&amp;lt;br&amp;gt;  INTO TABLE @DATA(lt_mat).&lt;BR /&gt;

Desired results:

2001  0002  D01  DE  Beschreibung für 2001&lt;BR /&gt;2002  0002  D01  EN  Description for 2002&lt;BR /&gt;2003  0002  D01  BG  Описание за 2004г&lt;/CODE&gt;&lt;/PRE&gt; 
  &lt;PRE&gt;&lt;CODE&gt;Any idea to solve it?&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 08 Apr 2022 13:55:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-join-with-priority-select/m-p/12490080#M2002440</guid>
      <dc:creator>jrgen_bauer</dc:creator>
      <dc:date>2022-04-08T13:55:08Z</dc:date>
    </item>
    <item>
      <title>Re: SQL-Join with priority select</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-join-with-priority-select/m-p/12490081#M2002441</link>
      <description>&lt;P&gt;Hi Jürgen, &lt;/P&gt;&lt;P&gt;you can do multiple LEFT OUTER JOINs, each for one language (SPRAS). The priorization will be implemented in the SELECT-List with &lt;A href="https://help.sap.com/doc/abapdocu_751_index_htm/7.51/de-DE/abensql_coalesce.htm"&gt;COALESCE&lt;/A&gt;. The code should look similar to this: &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT FROM marc  &lt;BR /&gt;LEFT OUTER JOIN makt AS text_DE&lt;BR /&gt;  ON marc~matnr = makt~matnr&lt;BR /&gt;  AND spras = 'D'&lt;BR /&gt;LEFT OUTER JOIN makt AS text_EN&lt;BR /&gt;  ON marc~matnr = makt~matnr&lt;BR /&gt;  AND spras = 'E'&lt;BR /&gt;LEFT OUTER JOIN makt AS text_BG&lt;BR /&gt;  ON marc~matnr = makt~matnr&lt;BR /&gt;  AND spras = 'BG' "???&lt;BR /&gt;  FIELDS&lt;BR /&gt;    marc~matnr,&lt;BR /&gt;    marc~werks,&lt;BR /&gt;    marc~dispo,&lt;BR /&gt;    coalesce(text_DE.spras,
             text_en.spras, &lt;BR /&gt;             text_bg.spras) as spras&lt;BR /&gt;     coalesce(text_DE.maktx,          &lt;BR /&gt;              text_en.maktx,                     &lt;BR /&gt;              text_bg.maktx) as maktx&lt;BR /&gt;  WHERE marc~matnr BETWEEN `000000000000002001` AND `000000000000002003`&lt;BR /&gt;    AND marc~werks = '0002'&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Regards, &lt;BR /&gt;Jörg&lt;/P&gt;</description>
      <pubDate>Fri, 08 Apr 2022 14:48:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-join-with-priority-select/m-p/12490081#M2002441</guid>
      <dc:creator>Jrg_Brandeis</dc:creator>
      <dc:date>2022-04-08T14:48:47Z</dc:date>
    </item>
    <item>
      <title>Re: SQL-Join with priority select</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-join-with-priority-select/m-p/12490082#M2002442</link>
      <description>&lt;P&gt;Hello Jörg&lt;/P&gt;&lt;P&gt;Thank you for sharing your ideas!&lt;/P&gt;&lt;P&gt;Unfortunately I don't know in which language the text is available. That would mean that I would have to check about 20 languages!&lt;/P&gt;&lt;P&gt;A select single or something similar would be helpful!&lt;BR /&gt;&lt;BR /&gt;Best Regards&lt;BR /&gt;Jürgen&lt;/P&gt;</description>
      <pubDate>Mon, 11 Apr 2022 10:00:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-join-with-priority-select/m-p/12490082#M2002442</guid>
      <dc:creator>jrgen_bauer</dc:creator>
      <dc:date>2022-04-11T10:00:51Z</dc:date>
    </item>
  </channel>
</rss>

