<?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 Re: ABAP SQL Select rows where a field has all specified values in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-sql-select-rows-where-a-field-has-all-specified-values/m-p/12736929#M2020823</link>
    <description>&lt;P&gt;&lt;SPAN class="mention-scrubbed"&gt;occoromomis&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;You can use the following SQL query to select rows where column A has values B1 and B2 at the same time:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT A FROM table_name WHERE B IN ('B1', 'B2') GROUP BY A HAVING COUNT(DISTINCT B) = 2;
&lt;/CODE&gt;&lt;/PRE&gt;Copy&lt;P&gt;This query selects all rows from the table where column B has values ‘B1’ or ‘B2’, groups them by column A and then filters out the groups that do not have both values ‘B1’ and ‘B2’ by using the HAVING clause with COUNT(DISTINCT B) = 2.&lt;/P&gt;&lt;P&gt;I hope this helps! Let me know if you have any other questions.&lt;/P&gt;</description>
    <pubDate>Mon, 29 May 2023 15:45:29 GMT</pubDate>
    <dc:creator>Yogananda</dc:creator>
    <dc:date>2023-05-29T15:45:29Z</dc:date>
    <item>
      <title>ABAP SQL Select rows where a field has all specified values</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-sql-select-rows-where-a-field-has-all-specified-values/m-p/12736928#M2020822</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
  &lt;P&gt;I have the following table:&lt;/P&gt;
  &lt;P&gt;A | B &lt;/P&gt;
  &lt;P&gt;A1 | B1&lt;/P&gt;
  &lt;P&gt;A1 | B2&lt;/P&gt;
  &lt;P&gt;A2 | B1&lt;/P&gt;
  &lt;P&gt;A2 | B2&lt;/P&gt;
  &lt;P&gt;A3 | B1&lt;/P&gt;
  &lt;P&gt;I need to select by SQL query the rows (column A) where column B has values B1 and B2 at the same time.&lt;BR /&gt;&lt;BR /&gt;So here the result should be &lt;/P&gt;
  &lt;P&gt;A1&lt;BR /&gt;A2&lt;/P&gt;
  &lt;P&gt;Because only A1 and A2 have rows with B1 and B2 &lt;BR /&gt;A3 has a row with B1 only so is not in the result.&lt;/P&gt;
  &lt;P&gt;How can I achieve this with SELECT statement please ?&lt;/P&gt;</description>
      <pubDate>Mon, 29 May 2023 15:24:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-sql-select-rows-where-a-field-has-all-specified-values/m-p/12736928#M2020822</guid>
      <dc:creator>former_member355261</dc:creator>
      <dc:date>2023-05-29T15:24:07Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP SQL Select rows where a field has all specified values</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-sql-select-rows-where-a-field-has-all-specified-values/m-p/12736929#M2020823</link>
      <description>&lt;P&gt;&lt;SPAN class="mention-scrubbed"&gt;occoromomis&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;You can use the following SQL query to select rows where column A has values B1 and B2 at the same time:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT A FROM table_name WHERE B IN ('B1', 'B2') GROUP BY A HAVING COUNT(DISTINCT B) = 2;
&lt;/CODE&gt;&lt;/PRE&gt;Copy&lt;P&gt;This query selects all rows from the table where column B has values ‘B1’ or ‘B2’, groups them by column A and then filters out the groups that do not have both values ‘B1’ and ‘B2’ by using the HAVING clause with COUNT(DISTINCT B) = 2.&lt;/P&gt;&lt;P&gt;I hope this helps! Let me know if you have any other questions.&lt;/P&gt;</description>
      <pubDate>Mon, 29 May 2023 15:45:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-sql-select-rows-where-a-field-has-all-specified-values/m-p/12736929#M2020823</guid>
      <dc:creator>Yogananda</dc:creator>
      <dc:date>2023-05-29T15:45:29Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP SQL Select rows where a field has all specified values</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-sql-select-rows-where-a-field-has-all-specified-values/m-p/12736930#M2020824</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;SELECT DISTINCT a
  FROM table_name AS t
  WHERE EXISTS ( SELECT * FROM table_name WHERE a = t~a AND b = 'B1' )
    AND EXISTS ( SELECT * FROM table_name WHERE a = t~a AND b = 'B2' )
  INTO TABLE @DATA(itab).&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 29 May 2023 15:50:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-sql-select-rows-where-a-field-has-all-specified-values/m-p/12736930#M2020824</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2023-05-29T15:50:07Z</dc:date>
    </item>
  </channel>
</rss>

