SELECT A~FTRMI
A~AUFNR
B~MATNR
D~MAKTX
B~PSMNG
B~WEMNG
C~MTART
E~CHARG
C~MATKL
C~SPART
R~BWART
R~CHARG
R~MATNR
E~BWART
R~BDMNG
INTO TABLE ITAB
FROM AFKO AS A INNER JOIN AFPO AS B ON A~AUFNR = B~AUFNR
* INNER JOIN AFVC AS A1 ON A~AUFPL = A1~AUFPL AND B~DWERK =
A1~WERKS
INNER JOIN MARA AS C ON B~MATNR = C~MATNR
INNER JOIN MAKT AS D ON C~MATNR = D~MATNR
INNER JOIN MSEG AS E ON B~MATNR = E~MATNR AND A~AUFNR =
E~AUFNR AND B~DWERK = E~WERKS
INNER JOIN RESB AS R ON A~AUFNR = R~AUFNR AND E~AUFNR =
R~AUFNR AND R~RSNUM = A~RSNUM
AND R~WERKS = E~WERKS AND R~BAUGR = E~MATNR
INNER JOIN MARA AS C1 ON R~MATNR = C1~MATNR
WHERE A~FTRMI IN S_DATE AND A~AUFNR IN S_AUFNR AND C~MTART
IN S_TYPE AND C~MATKL = 'T'
AND R~BWART ='261' AND E~BWART = '101'
AND R~XWAOK ='X' AND B~DWERK = '2000'
AND R~XLOEK EQ SPACE AND E~KZBEW ='F' AND D~SPRAS = 'E' AND
R~KZEAR = 'X' AND C~MATNR IN S_MATNR.


This query gives repetative records from RESB.There must be
some common field which i am not taking thats why its
giving repetative records. If u find any solution pls lety
me know ASAP.

Thanks
Swati Ghadge



SELECT A~FTRMI A~AUFNR B~MATNR D~MAKTX B~PSMNG B~WEMNG C~MTART E~CHARG C~MATKL C~SPART R~B..

Answer / Pankaj Verma

The issue with the given query is that it's joining the 'RESB' table multiple times, causing duplicate records. To fix this, you should remove one of the inner joins involving the 'RESB' table or use a GROUP BY clause to group by the common field(s) that cause the duplicates.nnHere's an example of using a GROUP BY clause:n```sqlnSELECT A~FTRMI A~AUFNR B~MATNR D~MAKTX B~PSMNG B~WEMNG C~MTART E~CHARG C~MATKL C~SPART R~BWART R~CHARG R~MATNR E~BWART R~MDMGN R~BDMNG INTO TABLE ITAB FROM AFKO AS A INNER JOIN AFPO AS B ON A~AUFNR = B~AUFNR * INNER JOIN AFVC AS A1 ON A~AUFPL = A1~AUFPL AND B~DWERK = A1~WERKS INNER JOIN MARA AS C ON B~MATNR = C~MATNR INNER JOIN MAKT AS D ON C~MATNR = D~MATNR INNER JOIN MSEG AS E ON B~MATNR = E~MATNR AND A~AUFNR = E~AUFNR AND B~DWERK = E~WERKSnINNER JOIN RESB AS R ON A~AUFNR = R~AUFNR AND E~AUFNR = R~AUFNR AND R~RSNUM = A~RSNUM AND R~WERKS = E~WERKS AND R~BAUGR = E~MATNR INNER JOIN MARA AS C1 ON R~MATNR = C1~MATNR WHERE A~FTRMI IN S_DATE AND A~AUFNR IN S_AUFNR AND C~MTART IN S_TYPE AND C~MATKL = 'T' AND R~BWART ='261' AND E~BWART = '101' AND R~XWAOK ='X' AND B~DWERK = '2000' AND R~XLOEK EQ SPACE AND E~KZBEW ='F' AND D~SPRAS = 'E' AND R~KZEAR = 'X' AND C~MATNR IN S_MATNRnGROUP BY A~AUFNR, B~MATNR, R~BWART, R~CHARG, R~MATNR, E~BWART, R~MDMGN, R~BDMNG;```

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Programming Languages AllOther Interview Questions

Difference between views and index in sas programming

1 Answers   Ventois,


why not instantiating servet using new operator?

1 Answers  


Diff.b/w Frames and container?

1 Answers   Tech Mahindra, Wipro,


what will we require to build project with the help of oracle

1 Answers  


1.What is difference between symget and & in sas? 2.what is difference between callsymput and %let?

1 Answers   CitiGroup,


how to avoid java script validation in client side validation?

2 Answers  


what is database?how to tell 3years boy or girl by using toys?

1 Answers  


major characteristics of software system

0 Answers  


Suppose server object is not loaded into the memory, and the client request for it , what will happen?

1 Answers  


What is a dialog based program

1 Answers  


hi This is radhika.Can anyone help me to know the question papers of NATIONAL INFORMATICS CENTRE for the post of scientific officer/engineer? if anyone know plz tell me question paper pattern

0 Answers  


how can we get version of database ?

1 Answers  


Categories