select 
	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 BYHK, 
	a.budatc,a.zfbdt,a.dqsjc,a.zterm,a.vbeln,a.pernr
from (
	select BUKRS,KUNNR,BLART,UMSKZ,WAERS,
	sum(case when shkzg='S' then WRBTR/-1 else 0 end) as WRBTR_S,
	sum(case when shkzg='H' then WRBTR else 0 end) as WRBTR_H,
	budatc,zfbdt,dqsjc,zterm,vbeln,pernr
	from bsid2bsad 
	where UMSKZ = '' and BLART in ('DZ', 'ZD')
	GROUP BY BUKRS,KUNNR,BLART,UMSKZ,WAERS,budatc,zfbdt,dqsjc,zterm,vbeln,pernr
) a
