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
.
An alternative approach is to use the logical OR (||) operator. To check if a value is of boolean type, check if the value is equal to false or equal to true , e.g. if (variable === true || variable === false) . Boolean values can only be true and false , so if either condition is met, the value has a type of boolean.
Syntax. Follow the below syntax to check for Boolean type variable using strict equality operator. If( variable === true || variable === false ) { // variable is of Boolean type. }
Boolean values and operations Constant true is 1 and constant false is 0. It is considered good practice, though, to write true and false in your program for boolean values rather than 1 and 0.
To initialize or assign a true or false value to a Boolean variable, we use the keywords true and false. Boolean values are not actually stored in Boolean variables as the words “true” or “false”. Instead, they are stored as integers: true becomes the integer 1, and false becomes the integer 0.
You can try with not
:
case
when varInt < XX and varBoo then 1.0
when varInt < XX and not(varBoo) then 0.5
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With