Query addition and subtraction of the same SQL field

I have the following inconvenience because I can add and subtract the same field in the same "Entries" table in a single query. It would be to add a SUM field (entry.ent_quantity) if the field entry.id_user = 0 and subtract this sum if the fieldentries.id_user <> 0. That means I get two sums from the same field, if the field id_user = 0 and if id_user <> 0 and these then add up the rest. Thanks in advance. I add the query code that I want to change

 $sql = "SELECT productos.id_producto as id_producto, productos.name, productos.marca, productos.proveedor, productos.stock_inicial, productos.fecha_ingreso, productos.nro_expediente,  productos.stock_actual, categorias.name, SUM(entradas.cantidad_ent)  FROM productos
   INNER JOIN categorias on  categorias.id_categoria = productos.id_categoria
   LEFT JOIN entradas on entradas.id_producto= productos.id_producto
   where productos.id_area='$id_area2'  and productos.precio_unidad != 0  group by id_producto ";

$query = mysqli_query($conn, $sql);

Optimization – Can gradient descent optimize (minimize one and maximize the other) the subtraction of two objective functions?

If the problem in a neural network is to optimize a parameter set and the loss function is as follows:

$$ E () = loss1 (a, b) – loss2 (b) $$

can minimize slopes $ E ( theta) $ in this problem, which means minimize $ loss1 $ and maximize $ loss2 $, In other words, we can find them $ theta $?

Javascript – value in Inner.Html returns NaN. Previously, the subtraction returned but was done only once. Then I would start adding

    

0