Hello experts!
I want to build a query that shows total invoiced and total credit memos grouped by a specific value (sales employee name)
The invoiced amount works but the total credit memo is shown as a total in every line instead of what corresponds to each line, it repeats the value.
Can someone help??

SELECT T5."SlpName", SUM (T3."DocTotal") AS FACTURACION, (SELECT distinct (-1*SUM (T4."DocTotal")) FROM ORIN T4 WHERE T4."BPLId" = T3."BPLId" AND (T4."DocDate">=[%1] AND T4."DocDate"<=[%2]) AND T4."CANCELED" = 'N') AS ABONOS FROM OINV T3 INNER JOIN OSLP T5 ON T3."SlpCode" = T5."SlpCode" WHERE T3."BPLId" = [%0] AND T3."DocDate">=[%1] AND T3."DocDate"<=[%2] AND T3."CANCELED" = 'N' Group By T3."BPLId", T5."SlpName"