Yo intentaría otro acercamiento:
Código SQL:
Ver originalSELECT
A.CardCode,
A.CardName,
A.DocNum,
(B2.ValorNeto - A.DiscSum) ValorNeto
FROM oinv A INNER JOIN
( SELECT B.DocEntry, SUM(B.Quantity * B.Price) ValorNeto
FROM inv1 B
GROUP BY B.DocEntry) B2 ON A.docentry = B2.DocEntry
WHERE A.docNum=30027
GROUP BY A.CardCode, A.CardName, A.DocNum