Desweiteren ist auch dieses Konstrukt nicht erforderlich:
case when sum(int(TPBMEN)) is NULL then 0 else sum(int(TPBMEN)) end
Man kann Aggregate und Einzelwerte nicht einfach mischen.
Hier reicht ein
coalesce(sum(int(TPBMEN)), 0)
Code:with temp_result as ( SELECT BMKONZ as NI, BMIDEN as Artikel, TZBEZ1 as Bezeichnung, BMLIEF as Lieferant, Count(BMLM) AS Paletten, Sum(int(BMBMEN)) AS Menge, ( select coalesce(sum(int(TPBMEN)), 0) from pbesttp where tpiden = bmiden and tpttyp in ('E', 'U') ) as Transport FROM PBESTLOL1 group by BMKONZ , BMIDEN , TZBEZ1 , BMLIEF )select * from temp_result
![[NEWSboard IBMi Forum]](images/duke/nblogo.gif)



Mit Zitat antworten
Bookmarks