Is there a function in SQL equivalent to IF
( SE
) of excel? I need to do a logical test that in excel I would write =SE(B1_UM = "UN"; D2_QUANT / B5_QE1;D2_QUANT)
.
Here is my query:
SELECT
D2_FILIAL,
// Um monte de coluna...
CASE
B1_UM
WHEN
'UN'
THEN
D2_QUANT / B5_QE1
ELSE
D2_QUANT
END AS CALC_QUANT
FROM
SD2010 SD2
// Vários joins
WHERE com várias condições
GROUP BY
D2_FILIAL,
// Várias outras colunas no group
CALC_QUANT