I have a script in SQL that in some of the fields I need to sum or perform a certain calculation on several fields
The problem is that instead of the sum it gives me several lines.
The code is:
select distinct
r1.U_Barcode U_RdrBarcode,
r1.DocEntry rdrEntry
,SUM(w1.U_Factor2)WoQnt
,r1.Factor2-SUM(w1.U_Factor2)OpenWoQnt
,SUM(w1.U_Factor2) WoTMr
,r1.Quantity - SUM(w1. U_Factor2) OpenWoTMr
from owor w join wor1 w1 on w.DocEntry=w1.DocEntry
join rdr1 r1 on w1.U_RdrBarcode=r1.U_Barcode
where w.DocEntry=@worEntry
group by r1.Quantity ,r1.U_Barcode,r1.DocEntry,r1.Factor2
The result I get is:
I need to get:
Would appreciate help.
Thanks