Wednesday 18 April 2018

GROUP BY Clause

The GROUP BY Clause combines groups of rows that have the same Record in their specified columns column1 column2, in the resulting set into a single row.
Group By clause categorizes and summarizes the lines of database table based on a single field or Multiple field, that field is mentioned in the group by clause.
and that  mentioned  fields in the group by clause cannot be specified for the aggregate function. We have to use another fields which are not specified in group by clause to calculate the aggregate function.
GROUP BY cannot be specified for pool tables and cluster tables .
the use of GROUP BY , the statement SELECT avoids the SAP buffering.
so that's why Fetching Data from database Table directly may be take some time.

example : 
DATA : BEGIN OF WA,
        VBELN      TYPE VBAP-VBELN,
        KWMENG TYPE VBAP-KWMENG,
        KBMENG  TYPE VBAP-KBMENG,
       END OF WA.

START-OF-SELECTION.
WRITE:/    'Sales doc. no',
        25 'Max Order Quantity',
        45 'Min Cumulative Confirmed Quantity'.
SELECT VBELN
       MAX( KWMENG ) MIN( KBMENG )
  FROM VBAP
  INTO (WA-VBELN,WA-KWMENG, WA-KBMENG)
  GROUP BY VBELN .

 WRITE:/   WA-VBELN,
         25 WA-KWMENG,
         45 WA-KBMENG.

 ENDSELECT.

No comments:

Post a Comment

In this post we use some basics Events  and Control Break Statements for Generating Classical Report Based On single Table. If You want so...