Koen
Koen

Reputation: 481

Shortcut for checking boolean false value

In java the following works:

boolean varBoo = true;

if(varBoo) means: if(varBoo = true) and

if(!varBoo) means: if(varBoo = false)

Im working on a postgreSQL statement right now, which looks like this:

CASE
  WHEN varInt < XX AND varBoo THEN 1.0    -- Short for varBoo = TRUE
  WHEN varInt < XX AND varBoo = FALSE THEN 0.5
END

Is there any way to write varBoo = FALSE shorter in PostgreSQL?

java equivalent would be !varBoo.

Upvotes: 6

Views: 547

Answers (1)

potashin
potashin

Reputation: 44601

You can try with not:

case
  when varInt < XX and varBoo then 1.0  
  when varInt < XX and not(varBoo) then 0.5
end

Upvotes: 3

Related Questions