florian86
Goto Top

Single-row query returns more than one row

Hallo Zusammen,

wie kann ich fett geschriebenen Teil in meiner Abfrage auch mit der der NSDM_V_MARD.MATNR (Materialnummer) füttern?

select ltrim(NSDM_V_MARD.MATNR,0),
        sum(NSDM_V_MARD.LABST)/(select MARM.UMREZ from SAPABAP1.MARM where MARM.MATNR = NSDM_V_MARD.MATNR and MARM.MEINH = 'KAR')-  
        (select sum(VBFA.RFMNG)/(select MARM.UMREZ from SAPABAP1.MARM where MARM.MATNR = NSDM_V_MARD.MATNR and MARM.MEINH = 'KAR') as K_Menge  
                from SAPABAP1.LIPS
                inner join SAPABAP1.VBFA on LIPS.MATNR = VBFA.MATNR and LIPS.VBELN = VBFA.VBELN and LIPS.POSNR = VBFA.POSNN
                inner join SAPABAP1.NSDM_V_MARD on LIPS.MATNR = NSDM_V_MARD.MATNR
                where LIPS.WERKS = '1000'   
                        and LIPS.LGORT = '2000'   


                        and LIPS.MATNR = 60062


                        and LIPS.GBSTA = 'B'   
                        and LIPS.WBSTA = 'A'  
                group by LIPS.VBELN, LIPS.MATNR, LIPS.POSNR, LIPS.WERKS, LIPS.LGORT, LIPS.CHARG, LIPS.ERDAT, VBFA.POSNN, NSDM_V_MARD.MATNR)
from SAPABAP1.NSDM_V_MARD
where MATNR between 60000 and 69999 
            and WERKS = '1000'   
            and LGORT = '2000'   
            and NSDM_V_MARD.LABST > 0
group by NSDM_V_MARD.MATNR,NSDM_V_MARD.WERKS,NSDM_V_MARD.LGORT

wenn ich LIPS.MATNR = NSDM_V_MARD.MATNR versuche bekomme ich "single-row query returns more than one row" als Fehler.

MfG

Florian86

Content-ID: 1285625539

Url: https://administrator.de/forum/single-row-query-returns-more-than-one-row-1285625539.html

Ausgedruckt am: 23.12.2024 um 16:12 Uhr

Florian86
Lösung Florian86 21.09.2021 um 08:51:44 Uhr
Goto Top
Konnte es selber mit einer verschachtelten Join Abfrage lösen

select ltrim(NSDM_V_MARD.MATNR,0),
        NSDM_V_MARD.LABST/(select MARM.UMREZ from SAPABAP1.MARM where MARM.MATNR = NSDM_V_MARD.MATNR and MARM.MEINH = 'KAR')-  
        sum(VBFA.RFMNG)/(select MARM.UMREZ from SAPABAP1.MARM where MARM.MATNR = NSDM_V_MARD.MATNR and MARM.MEINH = 'KAR') as K_Menge  
from SAPABAP1.NSDM_V_MARD inner join (SAPABAP1.VBFA inner join SAPABAP1.LIPS on (LIPS.MATNR = VBFA.MATNR) and (LIPS.VBELN = VBFA.VBELN) and (LIPS.POSNR = VBFA.POSNN)) on NSDM_V_MARD.MATNR = VBFA.MATNR
where NSDM_V_MARD.MATNR between 60000 and 69999
            and NSDM_V_MARD.WERKS = '1000'  
            and NSDM_V_MARD.LGORT = '2000'  
            and NSDM_V_MARD.LABST > 0
            and LIPS.GBSTA = 'B'  
            and LIPS.WBSTA = 'A'  
            and LIPS.WERKS = '1000'  
            and LIPS.LGORT = '2000'  
group by NSDM_V_MARD.MATNR,NSDM_V_MARD.WERKS,NSDM_V_MARD.LGORT, NSDM_V_MARD.LABST
order by NSDM_V_MARD.MATNR asc