Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Processing External Data →  ABAP Database Access →  ABAP SQL →  ABAP SQL - Operands and Expressions →  ABAP SQL - SQL Expressions sql_exp →  sql_exp - sql_win →  ABAP SQL - Examples of Window Expressions 

SQL Expressions, Window Expressions Without Partition

This example demonstrates window expressions without partition.

Other versions: 7.31 | 7.40 | 7.54

Source Code

    DATA(out) = cl_demo_output=>new( ).

    SELECT char1 && '_' && char2 AS group,
           num1,
           COUNT(*)      OVER( ) AS cnt,
           ROW_NUMBER( ) OVER( ) AS rnum,
           MIN( num1 )   OVER( ) AS min,
           MAX( num1 )   OVER( ) AS max,
           SUM( num1 )   OVER( ) AS sum,
           division( 100 * num1,
                     SUM( num1 ) OVER( ),
                     2 ) AS perc
           FROM demo_expressions
           ORDER BY group
           INTO TABLE @DATA(windowed).

    out->display( windowed ).

Description

The example defines the same columns as the executable example Window Expressions. There is, however, no PARTITION addition after OVER of the window expressions. This creates a single window that covers all rows in the results set to which the window functions are applied.