Olá,
Experimente esta consulta,
SELECT T0.[ItemCode],
T1.[WhsName],
v0.[Quantity] [WhsTotal],
T0.[BatchNum],
SUM(CASE T0.[Direction] when 0 then 1 else -1 end * T0.[Quantity]) [Quantity] FROM IBT1 T0 INNER JOIN OWHS T1 ON T0.WhsCode = T1.WhsCode
INNER JOIN (SELECT T0.[ItemCode], T1.[WhsName],
SUM(CASE T0.[Direction] when 0 then 1 else -1 end * T0.[Quantity]) [Quantity]
FROM IBT1 T0 INNER JOIN OWHS T1 ON T0.WhsCode = T1.WhsCode
GROUP BY T1.[WhsName], T0.[ItemCode]) V0 ON T0.[ItemCode]=V0.[ItemCode] and t1.[WhsName]=v0.[WhsName] WHERE T0.[ItemCode] =[%0] GROUP BY T0.[BatchNum], T1.[WhsName], v0.[Quantity], T0.[ItemCode]
Cumprimentos,
Nagarajan