<?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: An SQL chalenge in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/an-sql-chalenge/m-p/12540865#M2006089</link>
    <description>&lt;P&gt;Hi &lt;SPAN class="mention-scrubbed"&gt;ronaldo.silveiravieria&lt;/SPAN&gt;,&lt;/P&gt;&lt;P&gt;Open SQL offers windows functions now. &lt;/P&gt;&lt;P&gt;&lt;A href="https://help.sap.com/doc/abapdocu_755_index_htm/7.55/en-US/abensql_win_func.htm" target="test_blank"&gt;https://help.sap.com/doc/abapdocu_755_index_htm/7.55/en-US/abensql_win_func.htm&lt;/A&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;The window functions LEAD or LAG are suitable for calculations, such as determining the difference between values in the current row and values of the preceding or following rows.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;It could also works like this:&lt;/P&gt;&lt;P&gt;&lt;A href="https://stackoverflow.com/questions/30861919/what-is-rows-unbounded-preceding-used-for-in-teradata/30862368" target="test_blank"&gt;https://stackoverflow.com/questions/30861919/what-is-rows-unbounded-preceding-used-for-in-teradata/30862368&lt;/A&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;WITH data (t, a) AS (
  VALUES(1, 1),
        (2, 5),
        (3, 3),
        (4, 5),
        (5, 4),
        (6, 11)
)
SELECT t, a, sum(a) OVER (ORDER BY t ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
FROM data
ORDER BY t&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 19 Oct 2021 14:52:06 GMT</pubDate>
    <dc:creator>ThorstenHoefer</dc:creator>
    <dc:date>2021-10-19T14:52:06Z</dc:date>
    <item>
      <title>An SQL chalenge</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/an-sql-chalenge/m-p/12540862#M2006086</link>
      <description>&lt;P&gt;Hi guys, how are you today?&lt;/P&gt;
  &lt;P&gt;After burn a few neurons with part of my requirement, I'm forced to ask for your help &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;/P&gt;
  &lt;P&gt;I would like to solve this with pure SQL sentences in an AMDP method, I could solve this easily in ABAP, even in an AMDP method using loops, but as I said, I would like to solve this with SQL sentences, without use any kind of loops.&lt;/P&gt;
  &lt;P&gt;Please take a look on this image:&lt;/P&gt;
  &lt;P&gt;&lt;IMG alt="" /&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1983021-capture.png" /&gt;&lt;/P&gt;
  &lt;P&gt;I have 2 columns, the first I'll name as &lt;STRONG&gt;D&lt;/STRONG&gt; and the second as &lt;STRONG&gt;E&lt;/STRONG&gt;&lt;/P&gt;
  &lt;P&gt;The &lt;STRONG&gt;D&lt;/STRONG&gt; column, is a result of a SELECT SUM, but the &lt;STRONG&gt;E&lt;/STRONG&gt; colunm, is a calculated column, and it shoud work as follow:&lt;/P&gt;
  &lt;OL&gt; 
   &lt;LI&gt;Firsrt line are equals in both columns. &lt;STRONG&gt;E1 = D1 &lt;/STRONG&gt;&lt;/LI&gt; 
   &lt;LI&gt;In the second line, the calculation for the second column is &lt;STRONG&gt;E1 + D2&lt;/STRONG&gt;&lt;/LI&gt; 
   &lt;LI&gt;In the third line, the calculation for the second column is &lt;STRONG&gt;E2 + D3&lt;/STRONG&gt;&lt;/LI&gt; 
   &lt;LI&gt;In the forth line, the calculation for the second column is &lt;STRONG&gt;E3 + D4&lt;/STRONG&gt;&lt;/LI&gt; 
  &lt;/OL&gt;
  &lt;P&gt;And so on.&lt;/P&gt;
  &lt;P&gt;So tha's it. Is it posible solve this with pure SQL sentences?&lt;/P&gt;
  &lt;P&gt;Could someone please give me a help?&lt;/P&gt;
  &lt;P&gt;Best regards.&lt;/P&gt;
  &lt;P&gt;Ronaldo S. Vieira&lt;/P&gt;</description>
      <pubDate>Mon, 18 Oct 2021 20:13:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/an-sql-chalenge/m-p/12540862#M2006086</guid>
      <dc:creator>former_member202733</dc:creator>
      <dc:date>2021-10-18T20:13:25Z</dc:date>
    </item>
    <item>
      <title>Re: An SQL chalenge</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/an-sql-chalenge/m-p/12540863#M2006087</link>
      <description>&lt;P&gt;Also asked &lt;A href="https://stackoverflow.com/questions/69622709/an-sql-chalenge"&gt;here&lt;/A&gt; with currently one answer proposed.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Oct 2021 03:29:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/an-sql-chalenge/m-p/12540863#M2006087</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2021-10-19T03:29:08Z</dc:date>
    </item>
    <item>
      <title>Re: An SQL chalenge</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/an-sql-chalenge/m-p/12540864#M2006088</link>
      <description>&lt;P&gt;  &lt;SPAN class="mention-scrubbed"&gt;sandra.rossi&lt;/SPAN&gt; begging for your pardon. I ask in both forum (and ask here first) because stackoverflow is not only a SAP forum and other people that non SAP people could help me. The answer provided on the messge in stackoverflow, I've try it but it does not work.&lt;/P&gt;&lt;P&gt;By the way I'm a big fan of your posts.&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;P&gt;Ronaldo S. Vieira&lt;/P&gt;</description>
      <pubDate>Tue, 19 Oct 2021 13:38:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/an-sql-chalenge/m-p/12540864#M2006088</guid>
      <dc:creator>former_member202733</dc:creator>
      <dc:date>2021-10-19T13:38:19Z</dc:date>
    </item>
    <item>
      <title>Re: An SQL chalenge</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/an-sql-chalenge/m-p/12540865#M2006089</link>
      <description>&lt;P&gt;Hi &lt;SPAN class="mention-scrubbed"&gt;ronaldo.silveiravieria&lt;/SPAN&gt;,&lt;/P&gt;&lt;P&gt;Open SQL offers windows functions now. &lt;/P&gt;&lt;P&gt;&lt;A href="https://help.sap.com/doc/abapdocu_755_index_htm/7.55/en-US/abensql_win_func.htm" target="test_blank"&gt;https://help.sap.com/doc/abapdocu_755_index_htm/7.55/en-US/abensql_win_func.htm&lt;/A&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;The window functions LEAD or LAG are suitable for calculations, such as determining the difference between values in the current row and values of the preceding or following rows.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;It could also works like this:&lt;/P&gt;&lt;P&gt;&lt;A href="https://stackoverflow.com/questions/30861919/what-is-rows-unbounded-preceding-used-for-in-teradata/30862368" target="test_blank"&gt;https://stackoverflow.com/questions/30861919/what-is-rows-unbounded-preceding-used-for-in-teradata/30862368&lt;/A&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;WITH data (t, a) AS (
  VALUES(1, 1),
        (2, 5),
        (3, 3),
        (4, 5),
        (5, 4),
        (6, 11)
)
SELECT t, a, sum(a) OVER (ORDER BY t ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
FROM data
ORDER BY t&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 19 Oct 2021 14:52:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/an-sql-chalenge/m-p/12540865#M2006089</guid>
      <dc:creator>ThorstenHoefer</dc:creator>
      <dc:date>2021-10-19T14:52:06Z</dc:date>
    </item>
    <item>
      <title>Re: An SQL chalenge</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/an-sql-chalenge/m-p/12540866#M2006090</link>
      <description>&lt;P&gt;No problem. I'm just mentioning it for people who answer here so that they can know if the issue was solved and how. Thanks for the feedback.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Oct 2021 16:50:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/an-sql-chalenge/m-p/12540866#M2006090</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2021-10-19T16:50:10Z</dc:date>
    </item>
  </channel>
</rss>

