Ansicht
Dokumentation

ABENCDS_GROUP_BY_V1 - CDS GROUP BY V1

ABENCDS_GROUP_BY_V1 - CDS GROUP BY V1

General Data in Customer Master   General Data in Customer Master  
This documentation is copyright by SAP AG.
SAP E-Book

- DDIC-Based View, SELECT, GROUP BY

... GROUP BY field1, field2, ...
             path_expr1, path_expr2, ...


Effect

Groups those rows in the result set of a that have the same content in the elements specified by the fields field1, field2, ... or path expressions path_expr1, path_expr2 ... as a single row. The fields must be specified using the same names as the fields in the data source data_source. It is not allowed to use the alias names defined in the current CDS view using with AS.

The GROUP BY clause is mandatory if the SELECT list contains any aggregate expressions. All elements that are not defined using an aggregate expression must be listed after GROUP BY. Literals and other expressions cannot be specified after GROUP BY.

When the CDS view is accessed, the results of the aggregate expressions are calculated from the values of the corresponding fields of the combined rows and the results are placed in the element of the resulting row in the result set.

The fields specified after GROUP BY cannot be of the type LCHR, LRAW, STRING, RAWSTRING, or GEOM_EWKB.

Note

A WHERE condition is evaluated before the rows are combined using GROUP BY.

Example

When a CDS view is accessed, the view returns sales_order for every role of a business partner and returns the number of business partners and the total of all gross amounts for every currency.

@AbapCatalog.sqlViewName: 'SALES_ORDER_VW'
define view sales_order as
  select from snwd_so
    inner join
      snwd_bpa on buyer_guid = snwd_bpa.node_key
      { bp_role as role, //e.g. customer or supplier
        count(distinct buyer_guid) as partners_count,
        @Semantics.currencyCode snwd_so.currency_code,
        @Semantics.amount.currencyCode: 'currency_code'
          sum(snwd_so.gross_amount) as sum_gross_amount }
      group by bp_role, snwd_so.currency_code;






SUBST_MERGE_LIST - merge external lists to one complete list with #if... logic for R3up   BAL Application Log Documentation  
This documentation is copyright by SAP AG.

Length: 4233 Date: 20240419 Time: 150309     sap01-206 ( 47 ms )