1
I wanted to calculate the balance of an extract, since I have fields like extrato_tipo
and extrato_valor
, whereas the extrato_tipo
I use to be able to define whether the extract is input or output.
Example
extrato_id | extrato_tipo | extrato_data | extrato_valor
1 | e | 2021-05-09 | 500.00
2 | s | 2021-05-09 | 400.00
3 | e | 2021-05-09 | 500.00
4 | s | 2021-05-09 | 400.00
Where: e = input and s = output
If I add all the inputs and decrease by the sum of the outputs, it has to give 200 real. I’m having trouble assembling this query.
You can get the sum of all inputs and the sum of all outputs?
– Augusto Vasques
I managed to solve
– gabrielfalieri
pq I had mounted another query, before Ricardo reply, mark his as solution!
– gabrielfalieri