2
I need in a select to add a field, for this I need to check two conditions, if the currency is 3 divided by the exchange, if the operation is 18 take all the sum and multiply by -1. The select I have makes the sum by checking the currency, but can’t put two checks to make it negative when the operation is 18, because operation 18 is cancellation of registration.
SELECT SUM(IF(MOEDA=2,(VALOR/CAMBIO), VALOR)) VL FROM banco.CAIXA where DATA= '2018-11-06' AND OPERACAO IN(2,18)
Your question is not clear, I even tried to answer but before it is necessary to understand these conditions that should be in
if
. Note that you can put oneif
within itselfif
, as an example:IF(pais = 'Brasil', 'R$', IF(pais = 'Estados Unidos', '$', '€')) AS simboloMonetario
– Roberto de Campos