<?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: regarding select statement (max. and group by) in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-select-statement-max-and-group-by/m-p/1743647#M322845</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ravi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    Check this post.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://forums.sdn.sap.com/click.jspa?searchID=566912&amp;amp;messageID=1481350" target="test_blank"&gt;https://forums.sdn.sap.com/click.jspa?searchID=566912&amp;amp;messageID=1481350&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://forums.sdn.sap.com/click.jspa?searchID=566912&amp;amp;messageID=1910371" target="test_blank"&gt;https://forums.sdn.sap.com/click.jspa?searchID=566912&amp;amp;messageID=1910371&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Priyanka.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 02 Jan 2007 04:15:57 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-01-02T04:15:57Z</dc:date>
    <item>
      <title>regarding select statement (max. and group by)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-select-statement-max-and-group-by/m-p/1743645#M322843</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi champions,&lt;/P&gt;&lt;P&gt;                    &lt;/P&gt;&lt;P&gt;                    i need ur help ,i m having some problem in select max. and group by statement ,cud u plz explain this scenario with the help of eg...thnx in advance..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;warm regards,&lt;/P&gt;&lt;P&gt;ravi.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Jan 2007 04:01:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-select-statement-max-and-group-by/m-p/1743645#M322843</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-01-02T04:01:56Z</dc:date>
    </item>
    <item>
      <title>Re: regarding select statement (max. and group by)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-select-statement-max-and-group-by/m-p/1743646#M322844</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Max is used to fetch the record having maximm value say for some particular column like select max ( field 1 ) ....&lt;/P&gt;&lt;P&gt;and for group by see F1 help on select ,i pasted the same below - &lt;/P&gt;&lt;P&gt;Variants: &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;Variant 1 &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;Effect &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;Example &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;P&gt;&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;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Notes &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;Variant 2 &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;Effect &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;Note &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;Example &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;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note &lt;/P&gt;&lt;P&gt;Performance: &lt;/P&gt;&lt;P&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;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Jan 2007 04:04:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-select-statement-max-and-group-by/m-p/1743646#M322844</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-01-02T04:04:54Z</dc:date>
    </item>
    <item>
      <title>Re: regarding select statement (max. and group by)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-select-statement-max-and-group-by/m-p/1743647#M322845</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ravi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    Check this post.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://forums.sdn.sap.com/click.jspa?searchID=566912&amp;amp;messageID=1481350" target="test_blank"&gt;https://forums.sdn.sap.com/click.jspa?searchID=566912&amp;amp;messageID=1481350&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://forums.sdn.sap.com/click.jspa?searchID=566912&amp;amp;messageID=1910371" target="test_blank"&gt;https://forums.sdn.sap.com/click.jspa?searchID=566912&amp;amp;messageID=1910371&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Priyanka.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Jan 2007 04:15:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-select-statement-max-and-group-by/m-p/1743647#M322845</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-01-02T04:15:57Z</dc:date>
    </item>
    <item>
      <title>Re: regarding select statement (max. and group by)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-select-statement-max-and-group-by/m-p/1743648#M322846</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;&amp;lt;b&amp;gt;SELECT - group&amp;lt;/b&amp;gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Syntax &lt;/P&gt;&lt;P&gt;... GROUP BY { {col1 col2 ...} | (column_syntax) } ... . &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Effect &lt;/P&gt;&lt;P&gt;The addition GROUP BY combines groups of rows that have the same content in their specified columns col1 col2 ... in the resulting set into a single row. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The use of GROUP BY has the prerequisite that SELECT only individual columns, not all the columns, are specified using *. If GROUP BY is used, all columns that are specified directly after SELECT and not specified as an argument of an aggregate function must be listed there. Conversely, if GROUP BY is used, all the columns listed after SELECT that are not specified after GROUP BY must be specified as an argument of an aggregate function. The aggregate functions define how the content of these columns is determined in the combined row from the contents of all the rows of a group. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After GROUP BY, the same column identifiers must be specified as after SELECT. The specification can either be specified statically as a list col1 col2 ... or dynamically as a brackted data object column_syntax that - at execution of the statement - contains the syntax of the staticspecification or is set to initial value. For column_syntax, the same applies as for the dynamic column specification after SELECT. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the content of column_syntax initial, either all the rows or no rows at all are grouped together. The columns after SELECT must then be listed either solely as arguments of aggregate functions or solely directly. If not, prior to Release 6.10 you could trigger a runtime error. As of Release 6.10, this would trigger an exception CX_SY_OPEN_SQL_DB that can be handled. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The columns listed after GROUP BY must not be of type STRING or RAWSTRING, and if GROUP BY is used, pool or cluster tables cannot be accessed. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;select-MAX&amp;lt;/b&amp;gt; MAX( [DISTINCT] col ) Determines the maximum value of the value in the column col in the resulting set or in the current group. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;pankaj singh&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="3" type="ul"&gt;&lt;P&gt;mark all helpful answers&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Jan 2007 04:18:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-select-statement-max-and-group-by/m-p/1743648#M322846</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-01-02T04:18:18Z</dc:date>
    </item>
    <item>
      <title>Re: regarding select statement (max. and group by)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-select-statement-max-and-group-by/m-p/1743649#M322847</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you use aggregate functions together with one or more database fields in the SELECT clause , you must also all the database fields not specified by one of the aggregate functions under GROUP BY fields.&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;&lt;A href="http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/groupby_.htm" target="test_blank"&gt;http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/groupby_.htm&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Jan 2007 04:24:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-select-statement-max-and-group-by/m-p/1743649#M322847</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-01-02T04:24:47Z</dc:date>
    </item>
  </channel>
</rss>

