<?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 SELECT SUM not working in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-sum-not-working/m-p/4014508#M959208</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've got the bellow code  that works ok and gets 159 rows from the database:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
  SELECT a~werks a~fecha_dist b~matnr b~bdmng b~meins
    FROM zmtraz1 AS a INNER JOIN resb AS b
      ON a~resnr_01 = b~rsnum
    INTO TABLE gt_cargas
    WHERE a~fecha_dist IN gt_fechas_cargas.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But I want to use SUM with the field bdmng but it doesn't return me any result, only sy-subrc = 4 because nothing has been selected, what I'm doing wrong?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
  SELECT a~werks a~fecha_dist b~matnr SUM( b~bdmng ) b~meins
    FROM zmtraz1 AS a INNER JOIN resb AS b
      ON a~resnr_01 = b~rsnum
    INTO TABLE gt_cargas
    WHERE a~fecha_dist IN gt_fechas_cargas
    GROUP BY a~werks a~fecha_dist b~matnr b~meins.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 16 Jun 2008 14:21:52 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-06-16T14:21:52Z</dc:date>
    <item>
      <title>SELECT SUM not working</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-sum-not-working/m-p/4014508#M959208</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've got the bellow code  that works ok and gets 159 rows from the database:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
  SELECT a~werks a~fecha_dist b~matnr b~bdmng b~meins
    FROM zmtraz1 AS a INNER JOIN resb AS b
      ON a~resnr_01 = b~rsnum
    INTO TABLE gt_cargas
    WHERE a~fecha_dist IN gt_fechas_cargas.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But I want to use SUM with the field bdmng but it doesn't return me any result, only sy-subrc = 4 because nothing has been selected, what I'm doing wrong?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
  SELECT a~werks a~fecha_dist b~matnr SUM( b~bdmng ) b~meins
    FROM zmtraz1 AS a INNER JOIN resb AS b
      ON a~resnr_01 = b~rsnum
    INTO TABLE gt_cargas
    WHERE a~fecha_dist IN gt_fechas_cargas
    GROUP BY a~werks a~fecha_dist b~matnr b~meins.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Jun 2008 14:21:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-sum-not-working/m-p/4014508#M959208</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-16T14:21:52Z</dc:date>
    </item>
    <item>
      <title>Re: SELECT SUM not working</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-sum-not-working/m-p/4014509#M959209</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ups sorry, the code was OK my error was not in the statement.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Jun 2008 14:28:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-sum-not-working/m-p/4014509#M959209</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-16T14:28:10Z</dc:date>
    </item>
    <item>
      <title>Re: SELECT SUM not working</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-sum-not-working/m-p/4014510#M959210</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&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;&lt;/P&gt;&lt;P&gt;move the sum ( ) field to last i.e after meins.&lt;/P&gt;&lt;P&gt;and even change it in the internal table also.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Jun 2008 14:34:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-sum-not-working/m-p/4014510#M959210</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-16T14:34:10Z</dc:date>
    </item>
  </channel>
</rss>

