Good morning. I need to calculate between values that are stored in my DB, these values are marked with the + and - sign in their respective tables. I would like to know if there is any way to do that through a single SQL command I make these account: Add all values that have the + sign; Add all values that have the -; Decrease the result of one another;
The SQL command I've done so far is:
select sum(valeve) as valor from R046VER
where numemp = 404 and numcad = 4170 and codcal = 1136 and
codeve in (select codeve from R008INC where incfgm in('+', '-') and codtab = 1) and
tabeve = 1 and codeve not in(select codeve from R008EVC where codtab = 1
and crteve in('31B','31C','31E','31F','31G','31H','31I','31J','31M','39Z','39Z','39Z','49Z','50A','50F'))