I studied some SQL but I forgot everything and now I'm trying to do this database schema:
And I want to subtract of (all INGRESADO
- all CANTIDAD
) and return a unique value, something like this:
SELECT SUM(ingresado) - SUM(cantidad) FROM Nomina, Gasto;
But I think, it's not returning the real value I want...
Thanks!
EDIT:
DECLARE @nomina FLOAT;
DECLARE @gasto FLOAT;
SELECT @nomina = SUM(ingresado) FROM Nomina;
SELECT @gasto = SUM(cantidad) FROM Gasto;
SELECT @nomina - @gasto;
This return the value I want, but I want it in a unique query, THANKS.