Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

SQL Count on multiple fields

Former Member
0 Likes
1,085

Does anyone know if it is possible to create a count on multiple fields. I am trying to create an SQL statement that will indicate the number of Delivery Items in a Shipment.

The Delivery and Delivery-item need to be counted for each shipment. I was hoping to use something like the following but I can not get it passed the syntax checker:

select OI_SHNUM

count( distinct OI_DOCNR OI_ITEM )

from /BIC/AZOITRO0200

into table i_dlvCount_data

group by OI_SHNUM.

or

select OI_SHNUM

count( distinct OI_DOCNR )

count( distinct OI_ITEM )

from /BIC/AZOITRO0200

into table i_dlvCount_data

group by OI_SHNUM.

Any ideas appreciated. For the time being I will concatenate these in the preceeding BW data target.

1 REPLY 1
Read only

Former Member
0 Likes
693

This should work:

DATA: BEGIN OF i_dlvcount OCCURS 0,
        oi_shnum TYPE /bic/azoitro0200-oi_shnum,
        oi_docnr TYPE i,
        oi_item  TYPE i,
      END   OF i_dlvcount.

SELECT oi_shnum
       COUNT( DISTINCT oi_docnr )
       COUNT( DISTINCT oi_item )
  FROM /bic/azoitro0200
  INTO TABLE i_dlvcount_data.

Rob