Can you use logic operators with CASE / WHEN?

1

I'm trying to use logical operators with CASE / WHEN in SQL but I'm having difficulties, I need to give a response in case the result of the operation is less than 0 and another result for when the operation is > = 0

It makes a mistake if I put a logical operator there:

CASE (A + B + C)
    **WHEN >= 0** THEN 'RESPOSTA'
    ELSE 'SEM RESPOSTA'
END AS RESULTADO
    
asked by anonymous 12.02.2018 / 19:46

1 answer

5

Yes, you just have to put them right in WHEN :

CASE
    WHEN (A + B + C) >= 0 THEN 'RESPOSTA'
    ELSE 'SEM RESPOSTA'
END AS RESULTADO
    
12.02.2018 / 19:51