<?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 group by in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/help-with-group-by/m-p/2952718#M696328</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;you must always declare the field in you're selection on which you do the group by on. further on you have to define for the other field which value you want if more than 1 is possible through the group by. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT /bic/zps_vr_ds max(/bic/zps_ac_wk) max(/bic/zps_ev_hr)&lt;/P&gt;&lt;P&gt;FROM /bic/azps_ods600&lt;/P&gt;&lt;P&gt;INTO CORRESPONDING FIELDS OF TABLE b_tab&lt;/P&gt;&lt;P&gt;WHERE /bic/zps_wbs_d = project&lt;/P&gt;&lt;P&gt;GROUP BY /bic/zps_vr_ds.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;futher on I am not familiar with you're way of tables and fields so if there is an error in ther&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: &lt;/P&gt;&lt;P&gt;        A. de Smidt&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 15 Oct 2007 07:50:17 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-10-15T07:50:17Z</dc:date>
    <item>
      <title>help with group by</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/help-with-group-by/m-p/2952717#M696327</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hallow&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i need help with &amp;lt;b&amp;gt;group by&amp;lt;/b&amp;gt; statment &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i try like that and i have erorr&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT  /bic/zps_vr_ds  /bic/zps_ac_wk  /bic/zps_ev_hr  &lt;/P&gt;&lt;P&gt;  FROM /bic/azps_ods600&lt;/P&gt;&lt;P&gt;  INTO CORRESPONDING FIELDS OF TABLE b_tab&lt;/P&gt;&lt;P&gt;  WHERE /bic/zps_wbs_d = project&lt;/P&gt;&lt;P&gt;  GROUP BY /bic/zps_vr_ds.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the eroor is:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The field "/BIC/AZPS_ODS600~/BIC/ZPS_EV_HR" from the SELECT list is is	missing in the GROUP BY clause. is missing in the GROUP BY clause. is&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Oct 2007 07:47:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/help-with-group-by/m-p/2952717#M696327</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-15T07:47:06Z</dc:date>
    </item>
    <item>
      <title>Re: help with group by</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/help-with-group-by/m-p/2952718#M696328</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;you must always declare the field in you're selection on which you do the group by on. further on you have to define for the other field which value you want if more than 1 is possible through the group by. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT /bic/zps_vr_ds max(/bic/zps_ac_wk) max(/bic/zps_ev_hr)&lt;/P&gt;&lt;P&gt;FROM /bic/azps_ods600&lt;/P&gt;&lt;P&gt;INTO CORRESPONDING FIELDS OF TABLE b_tab&lt;/P&gt;&lt;P&gt;WHERE /bic/zps_wbs_d = project&lt;/P&gt;&lt;P&gt;GROUP BY /bic/zps_vr_ds.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;futher on I am not familiar with you're way of tables and fields so if there is an error in ther&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: &lt;/P&gt;&lt;P&gt;        A. de Smidt&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Oct 2007 07:50:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/help-with-group-by/m-p/2952718#M696328</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-15T07:50:17Z</dc:date>
    </item>
    <item>
      <title>Re: help with group by</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/help-with-group-by/m-p/2952719#M696329</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What exactly are you trying to do?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You use GROUP BY when you want to make use of aggregate operations eq min( ), max( ), sum ( ) etc.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;eg select a b sum( c )&lt;/P&gt;&lt;P&gt;     from mytable&lt;/P&gt;&lt;P&gt;     group by a b&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Each field in the select statement either needs to be listed in the GROUP BY clause, or have an aggregate function applied to it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Oct 2007 07:53:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/help-with-group-by/m-p/2952719#M696329</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-15T07:53:33Z</dc:date>
    </item>
    <item>
      <title>Re: help with group by</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/help-with-group-by/m-p/2952720#M696330</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi&lt;/P&gt;&lt;P&gt;good&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;pls check this code&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT result FROM source [INTO target] [WHERE condition] [GROUP BY fields] [ORDER BY order]. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT clause &lt;/P&gt;&lt;P&gt;Variants: &lt;/P&gt;&lt;P&gt;1. SELECT [SINGLE [FOR UPDATE] DISTINCT] * &lt;/P&gt;&lt;P&gt;2. SELECT [SINGLE [FOR UPDATE] DISTINCT] s1 ... sn &lt;/P&gt;&lt;P&gt;3. SELECT [SINGLE [FOR UPDATE] DISTINCT] (itab) &lt;/P&gt;&lt;P&gt;FROM clause &lt;/P&gt;&lt;P&gt;Variants: &lt;/P&gt;&lt;P&gt;1. ... FROM dbtab &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Additions: &lt;/P&gt;&lt;P&gt;1. ... CLIENT SPECIFIED &lt;/P&gt;&lt;P&gt;2. ... BYPASSING BUFFER &lt;/P&gt;&lt;P&gt;3. ... UP TO n ROWS &lt;/P&gt;&lt;P&gt;2. ... FROM (dbtabname) &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Additions: &lt;/P&gt;&lt;P&gt;1. ... CLIENT SPECIFIED &lt;/P&gt;&lt;P&gt;2. ... BYPASSING BUFFER &lt;/P&gt;&lt;P&gt;3. ... UP TO n ROWS &lt;/P&gt;&lt;P&gt;INTO target &lt;/P&gt;&lt;P&gt;(This form of the FROM clause works only in conjunction with the INTO clause.) &lt;/P&gt;&lt;P&gt;INTO clause &lt;/P&gt;&lt;P&gt;Variants: &lt;/P&gt;&lt;P&gt;1. ... INTO wa &lt;/P&gt;&lt;P&gt;2. ... INTO CORRESPONDING FIELDS OF wa &lt;/P&gt;&lt;P&gt;3. ... INTO (f1, ..., fn) &lt;/P&gt;&lt;P&gt;4. ... INTO TABLE itab &lt;/P&gt;&lt;P&gt;5. ... INTO CORRESPONDING FIELDS OF TABLE itab &lt;/P&gt;&lt;P&gt;6. ... APPENDING TABLE itab &lt;/P&gt;&lt;P&gt;7. ... APPENDING CORRESPONDING FIELDS OF TABLE itab &lt;/P&gt;&lt;P&gt;WHERE clause &lt;/P&gt;&lt;P&gt;Variants: &lt;/P&gt;&lt;P&gt;1. ... WHERE f op g &lt;/P&gt;&lt;P&gt;2. ... WHERE f [NOT] BETWEEN g1 AND g2 &lt;/P&gt;&lt;P&gt;3. ... WHERE f [NOT] LIKE g &lt;/P&gt;&lt;P&gt;4. ... WHERE f [NOT] IN (g1, ..., gn) &lt;/P&gt;&lt;P&gt;5. ... WHERE f [NOT] IN itab &lt;/P&gt;&lt;P&gt;6. ... WHERE f IS [NOT] NULL &lt;/P&gt;&lt;P&gt;7. ... WHERE NOT cond &lt;/P&gt;&lt;P&gt;8. ... WHERE cond1 AND cond2 &lt;/P&gt;&lt;P&gt;9. ... WHERE cond1 OR cond2 &lt;/P&gt;&lt;P&gt;10. ... WHERE (itab) &lt;/P&gt;&lt;P&gt;11. ... WHERE cond AND (itab) &lt;/P&gt;&lt;P&gt;12. ... FOR ALL ENTRIES IN itab WHERE cond&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Operator Meaning &lt;/P&gt;&lt;P&gt;EQ or = equal to &lt;/P&gt;&lt;P&gt;NE or &amp;lt; &amp;gt; not equal to &lt;/P&gt;&lt;P&gt;LT or &amp;lt; less than &lt;/P&gt;&lt;P&gt;LE or &amp;lt; = less than or equal to &lt;/P&gt;&lt;P&gt;GT or &amp;gt; greater than &lt;/P&gt;&lt;P&gt;GE or &amp;gt;= greater than or equal to &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;GROUP-BY clause &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Variants: &lt;/P&gt;&lt;P&gt;1. ... GROUP BY f1 ... fn &lt;/P&gt;&lt;P&gt;2. ... GROUP BY (itab) &lt;/P&gt;&lt;P&gt;ORDER-BY clause &lt;/P&gt;&lt;P&gt;Variants: &lt;/P&gt;&lt;P&gt;1. ... ORDER BY PRIMARY KEY &lt;/P&gt;&lt;P&gt;2. ... ORDER BY f1 ... fn &lt;/P&gt;&lt;P&gt;3. ... ORDER BY (itab) &lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;P&gt;reward point if helpful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;P&gt;mrutyun^&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Oct 2007 08:05:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/help-with-group-by/m-p/2952720#M696330</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-15T08:05:19Z</dc:date>
    </item>
    <item>
      <title>Re: help with group by</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/help-with-group-by/m-p/2952721#M696331</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi TAL,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Groups database table data in a SELECT command on one line in the result set. A group is a set of lines which all have the same values in each column determined by the field descriptors f1 ... fn. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;eg 1:&lt;/P&gt;&lt;P&gt;... GROUP BY f1 ... fn always requires a list in the SELECT clause. If you use field descriptors without an aggregate funciton in the SELECTclause, you must list them in the GROUP BY f1 ... fn clause. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&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;Note:&lt;/P&gt;&lt;P&gt;... GROUP BY f1 ... fn is not supported for pooled and cluster tables. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The columns f1, ..., fn must not be of the type STRING or RAWSTRING. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;eg :2&lt;/P&gt;&lt;P&gt;Works like GROUP BY f1 ... fn if the variable source_text contains the list f1 ... fn as ABAP source code. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Output all Lufthansa departure points with the number of destinations: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA:   BEGIN OF wa. &lt;/P&gt;&lt;P&gt;          INCLUDE STRUCTURE spfli. &lt;/P&gt;&lt;P&gt;DATA:     count TYPE I. &lt;/P&gt;&lt;P&gt;DATA:   END OF wa. &lt;/P&gt;&lt;P&gt;DATA:   field_list    TYPE STRING, &lt;/P&gt;&lt;P&gt;        group_by_list TYPE STRING, &lt;/P&gt;&lt;P&gt;        count TYPE I. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;field_list    = 'CITYFROM COUNT( * ) AS COUNT'. &lt;/P&gt;&lt;P&gt;group_by_list = 'CITYFROM'. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT DISTINCT (field_list) &lt;/P&gt;&lt;P&gt;       INTO CORRESPONDING FIELDS OF wa &lt;/P&gt;&lt;P&gt;       FROM spfli &lt;/P&gt;&lt;P&gt;       WHERE &lt;/P&gt;&lt;P&gt;         carrid   = 'LH' &lt;/P&gt;&lt;P&gt;       GROUP BY (group_by_list). &lt;/P&gt;&lt;P&gt;  WRITE: / wa-cityfrom, wa-count. &lt;/P&gt;&lt;P&gt;ENDSELECT. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If aggregates and groups are formed by the database system and not just by the application server, this helps to reduce considerably the volume of data that has to be transported from the database server to the application server. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward if Useful,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Chitra&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Oct 2007 08:07:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/help-with-group-by/m-p/2952721#M696331</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-15T08:07:50Z</dc:date>
    </item>
    <item>
      <title>Re: help with group by</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/help-with-group-by/m-p/2952722#M696332</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;SELECT objid gjahr accrule acrtype effdate INTO CORRESPONDING FIELDS OF&lt;/P&gt;&lt;P&gt;TABLE parent_class-&amp;gt;acepsoit_table_ FROM acepsoit&lt;/P&gt;&lt;P&gt;WHERE bukrs IN parent_class-&amp;gt;company_code_range&lt;/P&gt;&lt;P&gt;AND acrtype IN parent_class-&amp;gt;accrual_type_range&lt;/P&gt;&lt;P&gt;AND accrule IN parent_class-&amp;gt;acct_principle_range&lt;/P&gt;&lt;P&gt;AND effdate IN parent_class-&amp;gt;key_date_range&lt;/P&gt;&lt;P&gt;AND poyear IN parent_class-&amp;gt;fiscal_yr_range&lt;/P&gt;&lt;P&gt;GROUP BY effdate objid gjahr accrule acrtype.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Oct 2007 08:11:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/help-with-group-by/m-p/2952722#M696332</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-15T08:11:27Z</dc:date>
    </item>
    <item>
      <title>Re: help with group by</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/help-with-group-by/m-p/2952723#M696333</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;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;u&amp;gt;&amp;lt;b&amp;gt;Variants:&amp;lt;/b&amp;gt;&amp;lt;/u&amp;gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. ... GROUP BY f1 ... fn &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. ... GROUP BY (source_text) &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;u&amp;gt;&amp;lt;b&amp;gt;Variant 1&amp;lt;/b&amp;gt;&amp;lt;/u&amp;gt; &lt;/P&gt;&lt;P&gt;... GROUP BY f1 ... fn &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;u&amp;gt;&amp;lt;b&amp;gt;Effect&amp;lt;/b&amp;gt;&amp;lt;/u&amp;gt; &lt;/P&gt;&lt;P&gt;Groups database table data in a SELECT command on one line in the result set. A group is a set of lines which all have the same values in each column determined by the field descriptors f1 ... fn. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;... GROUP BY f1 ... fn always requires a list in the SELECT clause. If you use field descriptors without an aggregate funciton in the SELECTclause, you must list them in the GROUP BY f1 ... fn clause. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;u&amp;gt;&amp;lt;b&amp;gt;Example&amp;lt;/b&amp;gt;&amp;lt;/u&amp;gt; &lt;/P&gt;&lt;P&gt;Output the number of passengers, the total weight and the average weight of luggage for all Lufthansa flights on 28.02.2001: &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;


DATA:  count TYPE I, sum TYPE P DECIMALS 2, avg TYPE F. 
DATA:  connid TYPE sbook-connid. 

SELECT connid COUNT( * ) SUM( luggweight ) AVG( luggweight ) 
       INTO (connid, count, sum, avg) 
       FROM sbook 
       WHERE 
         carrid   = 'LH'       AND 
         fldate   = '20010228' 
       GROUP BY connid. 
  WRITE: / connid, count, sum, avg. 
ENDSELECT.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;u&amp;gt;&amp;lt;b&amp;gt;Notes&amp;lt;/b&amp;gt;&amp;lt;/u&amp;gt; &lt;/P&gt;&lt;P&gt;... GROUP BY f1 ... fn is not supported for pooled and cluster tables. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The columns f1, ..., fn must not be of the type STRING or RAWSTRING. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;u&amp;gt;&amp;lt;b&amp;gt;Variant 2&amp;lt;/b&amp;gt;&amp;lt;/u&amp;gt; &lt;/P&gt;&lt;P&gt;... GROUP BY (source_text) &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;u&amp;gt;&amp;lt;b&amp;gt;Effect&amp;lt;/b&amp;gt;&amp;lt;/u&amp;gt; &lt;/P&gt;&lt;P&gt;Works like GROUP BY f1 ... fn if the variable source_text contains the list f1 ... fn as ABAP source code. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;u&amp;gt;&amp;lt;b&amp;gt;Note&amp;lt;/b&amp;gt;&amp;lt;/u&amp;gt; &lt;/P&gt;&lt;P&gt;The same restrictions apply to this variant as to GROUP BY f1 ... fn. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;i&amp;gt;&amp;lt;b&amp;gt;Example&amp;lt;/b&amp;gt;&amp;lt;/i&amp;gt; &lt;/P&gt;&lt;P&gt;Output all Lufthansa departure points with the number of destinations: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA:   BEGIN OF wa. 
          INCLUDE STRUCTURE spfli. 
DATA:     count TYPE I. 
DATA:   END OF wa. 
DATA:   field_list    TYPE STRING, 
        group_by_list TYPE STRING, 
        count TYPE I. 

field_list    = 'CITYFROM COUNT( * ) AS COUNT'. 
group_by_list = 'CITYFROM'. 

SELECT DISTINCT (field_list) 
       INTO CORRESPONDING FIELDS OF wa 
       FROM spfli 
       WHERE 
         carrid   = 'LH' 
       GROUP BY (group_by_list). 
  WRITE: / wa-cityfrom, wa-count. 
ENDSELECT.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;Note &lt;/P&gt;&lt;P&gt;Performance:&amp;lt;/b&amp;gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If aggregates and groups are formed by the database system and not just by the application server, this helps to reduce considerably the volume of data that has to be transported from the database server to the application server. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Pavan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Oct 2007 08:12:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/help-with-group-by/m-p/2952723#M696333</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-15T08:12:19Z</dc:date>
    </item>
  </channel>
</rss>

