Is there any way to use logical operators with CASE/WHEN?

Asked

Viewed 433 times

1

I am trying to use logical operators with CASE/WHEN in SQL but I am having difficulties, I need to present an answer if the result of the operation is less than 0 and another result for when the operation is >= 0

It’s wrong if I put a logical operator there:

CASE (A + B + C)
    **WHEN >= 0** THEN 'RESPOSTA'
    ELSE 'SEM RESPOSTA'
END AS RESULTADO

1 answer

5


Yeah, you just need to put them right on WHEN:

CASE
    WHEN (A + B + C) >= 0 THEN 'RESPOSTA'
    ELSE 'SEM RESPOSTA'
END AS RESULTADO
  • 1

    Thanks guy I managed to finish my Query

Browser other questions tagged

You are not signed in. Login or sign up in order to post.