0
I am trying to sum two columns after subtracting the following way in sql:
SELECT sum(valor) WHERE lancamentotipo = "R" - sum(valor) WHERE lancamentotipo = "D" from lancamentos
From the above by adding a "WHERE" clause I get error however if I do it as follows it works:
SELECT sum(valor) - sum(valor2) from lancamentos
How do I insert a "WHERE" clause correctly in the above case, because I’m sure I’m missing something simple, because I want to add and subtract values from the same table with a certain condition.