<?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: Help with SQL Query in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/help-with-sql-query/m-p/12630042#M2013270</link>
    <description>&lt;P&gt;Depending on your version, you could use a simple SELECT with the &lt;A href="https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/abapunion.htm#!ABAP_ONE_ADD@1@"&gt;UNION DISTINCT&lt;/A&gt; option.&lt;/P&gt;</description>
    <pubDate>Fri, 26 Aug 2022 08:44:12 GMT</pubDate>
    <dc:creator>RaymondGiuseppi</dc:creator>
    <dc:date>2022-08-26T08:44:12Z</dc:date>
    <item>
      <title>Help with SQL Query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/help-with-sql-query/m-p/12630037#M2013265</link>
      <description>&lt;P&gt;Could someone kindly help with below? Essentially it is giving me error once I nest the SQL query.&lt;/P&gt;
  &lt;P&gt;Currently column1 and the FROM (before table_a ) and GROUP are highlighted in red. &lt;/P&gt;
  &lt;P&gt;The error message reads: column1 is invalid here (due to grammar).&lt;/P&gt;
  &lt;P&gt;What am I missing here? Thanks in advance!!&lt;/P&gt;
  &lt;P&gt;SELECT column1, count( * )&lt;BR /&gt; FROM&lt;BR /&gt; (&lt;BR /&gt; SELECT column1, column2&lt;BR /&gt; FROM table_a&lt;BR /&gt; UNION&lt;BR /&gt; SELECT column1, column2&lt;BR /&gt; FROM table_b&lt;BR /&gt; )&lt;/P&gt;
  &lt;P&gt;GROUP BY column1&lt;/P&gt;
  &lt;P&gt; INTO TABLE @gt_output.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Aug 2022 06:55:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/help-with-sql-query/m-p/12630037#M2013265</guid>
      <dc:creator>former_member1332171</dc:creator>
      <dc:date>2022-08-26T06:55:14Z</dc:date>
    </item>
    <item>
      <title>Re: Help with SQL Query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/help-with-sql-query/m-p/12630038#M2013266</link>
      <description>&lt;P&gt;Hello Terris,&lt;/P&gt;&lt;P&gt;I'm not too deep into SQL, so I cannot see an error directly.&lt;/P&gt;&lt;P&gt;1) What is the actual error message?&lt;/P&gt;&lt;P&gt;2) Does it work without the Union?&lt;/P&gt;&lt;P&gt;3) maybe Count ( Column2) is better? There is only Column 2 left to count, right?&lt;/P&gt;&lt;P&gt;BR, Martin&lt;/P&gt;</description>
      <pubDate>Fri, 26 Aug 2022 07:06:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/help-with-sql-query/m-p/12630038#M2013266</guid>
      <dc:creator>MKreitlein</dc:creator>
      <dc:date>2022-08-26T07:06:27Z</dc:date>
    </item>
    <item>
      <title>Re: Help with SQL Query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/help-with-sql-query/m-p/12630039#M2013267</link>
      <description>&lt;P&gt;Hi Martin, thanks for your response! I updated my question above to simplify the query. Could you please see if it is more clear? Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 26 Aug 2022 07:15:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/help-with-sql-query/m-p/12630039#M2013267</guid>
      <dc:creator>former_member1332171</dc:creator>
      <dc:date>2022-08-26T07:15:26Z</dc:date>
    </item>
    <item>
      <title>Re: Help with SQL Query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/help-with-sql-query/m-p/12630040#M2013268</link>
      <description>&lt;P&gt;Please use the button COMMENT if it's just about to provide information or reply to someone. The button ANSWER is only for providing the solutions, as you can see the text from SAP when you answer "Please provide a distinct answer and use the comment option for clarifying purposes" &lt;/P&gt;</description>
      <pubDate>Fri, 26 Aug 2022 08:16:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/help-with-sql-query/m-p/12630040#M2013268</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2022-08-26T08:16:46Z</dc:date>
    </item>
    <item>
      <title>Re: Help with SQL Query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/help-with-sql-query/m-p/12630041#M2013269</link>
      <description>&lt;P&gt;ABAP SQL evolves a lot at each ABAP version, so please indicate what version you are using.&lt;/P&gt;&lt;P&gt;But I think there's no version to permit your syntax with nested SELECT.&lt;/P&gt;&lt;P&gt;Instead, you might be just keep the SELECT ... UNION SELECT ... but append distinct to the union (UNION DISTINCT) and that's it.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Aug 2022 08:24:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/help-with-sql-query/m-p/12630041#M2013269</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2022-08-26T08:24:33Z</dc:date>
    </item>
    <item>
      <title>Re: Help with SQL Query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/help-with-sql-query/m-p/12630042#M2013270</link>
      <description>&lt;P&gt;Depending on your version, you could use a simple SELECT with the &lt;A href="https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/abapunion.htm#!ABAP_ONE_ADD@1@"&gt;UNION DISTINCT&lt;/A&gt; option.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Aug 2022 08:44:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/help-with-sql-query/m-p/12630042#M2013270</guid>
      <dc:creator>RaymondGiuseppi</dc:creator>
      <dc:date>2022-08-26T08:44:12Z</dc:date>
    </item>
    <item>
      <title>Re: Help with SQL Query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/help-with-sql-query/m-p/12630043#M2013271</link>
      <description>&lt;P&gt;Note that UNION alone does a DISTINCT implicitly (same as UNION DISTINCT).&lt;/P&gt;&lt;P&gt;So, this is just fine:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT column1, column2
FROM table_a
UNION
SELECT column1, column2
FROM table_b
INTO TABLE @gt_output.&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 26 Aug 2022 08:45:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/help-with-sql-query/m-p/12630043#M2013271</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2022-08-26T08:45:44Z</dc:date>
    </item>
    <item>
      <title>Re: Help with SQL Query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/help-with-sql-query/m-p/12630044#M2013272</link>
      <description>&lt;P&gt;Hi Sandra, &lt;/P&gt;&lt;P&gt;Thanks so much for your comment. I realized the UNION thing after I posted this. However, the main issue seems it does not like the nested subquery. &lt;/P&gt;&lt;P&gt;I updated my query now to simplify the union part, but added a group by clause. It is still giving similar errors. Would you mind helping take a look?&lt;/P&gt;&lt;P&gt;Thanks so much!&lt;/P&gt;&lt;P&gt;Terris&lt;/P&gt;</description>
      <pubDate>Fri, 26 Aug 2022 14:10:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/help-with-sql-query/m-p/12630044#M2013272</guid>
      <dc:creator>former_member1332171</dc:creator>
      <dc:date>2022-08-26T14:10:18Z</dc:date>
    </item>
  </channel>
</rss>

