SELECT COALESCE(SUM((price/priceper)*QtyRequired),0) as total_value,
COALESCE(SUM((price/priceper)*QtyRequired),0) as outstanding_value
FROM @Item i
LEFT OUTER JOIN @OrderItem o ON i.Id = o.ItemId
WHERE i.Id = @ItemIdTest
group by itemId
时间: 2024-10-25 06:17:27