Maybe try using:
$addSQL = " WHERE (ProductStock - (SELECT Coalesce(SUM(DetailQuantity),0) FROM orders Inner Join orderdetails ON orderdetails.DetailOrderID = orders.OrderID WHERE OrderDate > ProductUpdateDate AND DetailProductID = ProductID)) BETWEEN 1 AND Coalesce(AmberStock,4)";
I'm not sure if the extra parenthesis will help, but it seems like it might.