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

How to count multi table's records in one sql statement ?

carlos_zhang3
Participant
0 Likes
362

Dear Guru ,

I have 3 tables : mara , mvke , marc .

and now i would like to count the LVORM field if the material code is : A .....

I need these count result save in one internal table , jus like that :

matnr mara mvke marc

A 0 2 1

......

....

Is it possible to do that in one sql statement ?

here is my code , but it failure ....

SELECT A~MATNR

count( distinct A~LVORM ) as lvorm1

count( distinct B~LVORM ) as lvorm2

count( distinct C~LVORM ) as lvorm3

INTO CORRESPONDING FIELDS OF TABLE it_tab

FROM MARA AS A , MVKE AS B , MARC AS C

FOR ALL ENTRIES IN IT_MARA

WHERE ( A~MATNR = it_mara-matnr

AND B~MATNR = it_mara-matnr

AND C~MATNR = it_mara-matnr )

AND

( ALVORM = 'X' OR BLVORM = 'X' OR C~LVORM = 'X' )

group by a~matnr .

Please help ...

Thanks .

Best Rds,

Carlos

1 REPLY 1
Read only

Former Member
0 Likes
320

How exactly does it fail?

Rob