select 
	a.mandt,a.BUKRS,a.KUNNR,a.BLART,a.UMSKZ,a.WAERS, 
	round(a.WRBTR_S,2) as WRBTR_S, round(a.WRBTR_H,2) as WRBTR_H, round((a.WRBTR_S + a.WRBTR_H),2) as BYXSE, 
	a.budatd,a.zfbdt,a.dqsjc,a.zterm,a.vbeln
from (
	select mandt,BUKRS,KUNNR,BLART,UMSKZ,WAERS,
	sum(case when shkzg='S' then WRBTR else 0 end) as WRBTR_S,
	sum(case when shkzg='H' then WRBTR/-1 else 0 end) as WRBTR_H,
	budatd,zfbdt,dqsjc,zterm,vbeln
	from bsid2bsad 
	where UMSKZ = '' and BLART in ('RV', 'QC')
	GROUP BY mandt,BUKRS,KUNNR,BLART,UMSKZ,WAERS,budatd,zfbdt,dqsjc,zterm,vbeln
) a
