hello good morning I have the following problem I need to get the difference between two fields. These fields I have to add the total of all their values and then do the subtraction BUT I THROW ANY RESULT ONCE MADE THE REST
SINCE I AM THANK YOUR RESPONSES
SELECT SUM(ovd.precio_unitario_final) - SUM(pd.suma_pago) AS
diferencia
FROM pagos p
INNER JOIN orden_venta as ov on p.id_ov = ov.id_ov
INNER JOIN pagos_detalle as pd on p.id_pago = pd.id_pago
INNER JOIN orden_venta_detalle as ovd on ov.id_ov = ovd.id_ov
GROUP BY ovd.precio_unitario_final , pd.suma_pago