<?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: Group By? in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/group-by/m-p/1506297#M233956</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The Group by clause is used in the SELECT statement when you wish to aggregrate certain values in the table for a particular combination...u can use aggregrate functions like max, min, sum, count etc...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The alternative is to calculate the same using abap logic..basically selecting the data into an internal table and when you loop through the data to do the calculation using on change or at events.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Anurag&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 28 Aug 2006 09:52:59 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2006-08-28T09:52:59Z</dc:date>
    <item>
      <title>Group By?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/group-by/m-p/1506293#M233952</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Where and why do we use Group By with a SELECT statement?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there any alternative to Group by in ABAP?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Aug 2006 09:28:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/group-by/m-p/1506293#M233952</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-08-28T09:28:11Z</dc:date>
    </item>
    <item>
      <title>Re: Group By?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/group-by/m-p/1506294#M233953</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; in selects if u want to use aggregate functions like max min avg .. then u have to use Group by on that filed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ex: Select MAX( VERSION ) from tablexy into temp_version&lt;/P&gt;&lt;P&gt;where OBJECT = temp_object&lt;/P&gt;&lt;P&gt;group by version.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To know more about GROUP BY,Just check out this link&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/groupby_.htm&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Ashok P&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Aug 2006 09:31:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/group-by/m-p/1506294#M233953</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-08-28T09:31:23Z</dc:date>
    </item>
    <item>
      <title>Re: Group By?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/group-by/m-p/1506295#M233954</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The GROUP BY clause allows you to summarize lines that have the same content in particular columns. Aggregate functions are applied to the other columns. You can specify the columns in the GROUP BY clause either statically or dynamically.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To specify the columns in the GROUP BY clause statically, use: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT &amp;lt;lines&amp;gt; &amp;lt;s1&amp;gt; [AS &amp;lt;a 1&amp;gt;] &amp;lt;s 2&amp;gt; [AS &amp;lt;a 2&amp;gt;] ... &lt;/P&gt;&lt;P&gt;               &amp;lt;agg&amp;gt; &amp;lt;sm&amp;gt; [AS &amp;lt;a m&amp;gt;] &amp;lt;agg&amp;gt; &amp;lt;s n&amp;gt; [AS &amp;lt;a n&amp;gt;] ... &lt;/P&gt;&lt;P&gt;       ...&lt;/P&gt;&lt;P&gt;       GROUP BY &amp;lt;s1&amp;gt; &amp;lt;s 2&amp;gt; ....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To use the GROUP BY clause, you must specify all of the relevant columns in the SELECT clause. In the GROUP BY clause, you list the field names of the columns whose contents must be the same. You can only use the field names as they appear in the database table. Alias names from the SELECT clause are not allowed. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;All columns of the SELECT clause that are not listed in the GROUP BY clause must be included in aggregate functions. This defines how the contents of these columns is calculated when the lines are summarized.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Aug 2006 09:47:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/group-by/m-p/1506295#M233954</guid>
      <dc:creator>sushant_singh</dc:creator>
      <dc:date>2006-08-28T09:47:11Z</dc:date>
    </item>
    <item>
      <title>Re: Group By?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/group-by/m-p/1506296#M233955</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Refer this sample code:&lt;/P&gt;&lt;P&gt;DATA:  count TYPE I, sum TYPE P DECIMALS 2, avg TYPE F. &lt;/P&gt;&lt;P&gt;DATA:  connid TYPE sbook-connid. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT connid COUNT( * ) SUM( luggweight ) AVG( luggweight ) &lt;/P&gt;&lt;P&gt;       INTO (connid, count, sum, avg) &lt;/P&gt;&lt;P&gt;       FROM sbook &lt;/P&gt;&lt;P&gt;       WHERE &lt;/P&gt;&lt;P&gt;         carrid   = 'LH'       AND &lt;/P&gt;&lt;P&gt;         fldate   = '20010228' &lt;/P&gt;&lt;P&gt;       GROUP BY connid. &lt;/P&gt;&lt;P&gt;  WRITE: / connid, count, sum, avg. &lt;/P&gt;&lt;P&gt;ENDSELECT. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;ravi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Aug 2006 09:47:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/group-by/m-p/1506296#M233955</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-08-28T09:47:22Z</dc:date>
    </item>
    <item>
      <title>Re: Group By?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/group-by/m-p/1506297#M233956</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The Group by clause is used in the SELECT statement when you wish to aggregrate certain values in the table for a particular combination...u can use aggregrate functions like max, min, sum, count etc...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The alternative is to calculate the same using abap logic..basically selecting the data into an internal table and when you loop through the data to do the calculation using on change or at events.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Anurag&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Aug 2006 09:52:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/group-by/m-p/1506297#M233956</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-08-28T09:52:59Z</dc:date>
    </item>
    <item>
      <title>Re: Group By?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/group-by/m-p/1506298#M233957</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Let us take an example,&lt;/P&gt;&lt;P&gt;We have a table with three fields&lt;/P&gt;&lt;P&gt;EmpNo Month Salary&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="--------------------------" /&gt;&lt;P&gt;1     Jan   10000&lt;/P&gt;&lt;P&gt;2     Jan    8000&lt;/P&gt;&lt;P&gt;3     Jan   15000&lt;/P&gt;&lt;P&gt;1     Feb   10500&lt;/P&gt;&lt;P&gt;2     Feb    8200&lt;/P&gt;&lt;P&gt;3     Feb   15100&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-----------------------------" /&gt;&lt;P&gt;  &lt;/P&gt;&lt;P&gt;This table gives the salary for the employee in monthly basis. &lt;/P&gt;&lt;P&gt;Let us assume that you wanted to calculata the total salary of each employee&lt;/P&gt;&lt;P&gt;The output would be&lt;/P&gt;&lt;P&gt;EmpNO  Salary&lt;/P&gt;&lt;P&gt;1      20500&lt;/P&gt;&lt;P&gt;2      16200 &lt;/P&gt;&lt;P&gt;3      30100&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="------------------------------------------" /&gt;&lt;P&gt;In order to get the result you should use the aggregate function "sum" and the "group by" option in the select.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The other option is to download all values from the table in itab and sort the itab by empno.&lt;/P&gt;&lt;P&gt;Then loop itab, &lt;/P&gt;&lt;P&gt;loop at itab.&lt;/P&gt;&lt;P&gt;  at new empno.&lt;/P&gt;&lt;P&gt;     clear tot_sal.&lt;/P&gt;&lt;P&gt;  endat.&lt;/P&gt;&lt;P&gt;     tot_sal = tot_sal + sal.&lt;/P&gt;&lt;P&gt;  at end of empno.&lt;/P&gt;&lt;P&gt;     write empno tot_sal.&lt;/P&gt;&lt;P&gt;    &lt;/P&gt;&lt;P&gt;  endat.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Kanthimathi Krishnan&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Aug 2006 10:02:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/group-by/m-p/1506298#M233957</guid>
      <dc:creator>kanthimathikris</dc:creator>
      <dc:date>2006-08-28T10:02:07Z</dc:date>
    </item>
  </channel>
</rss>

