Boolean Operators

Vertica supports the following Boolean operators:

  • AND
  • OR
  • NOT

Operators AND and OR are commutative, that is, you can switch left and right operands without affecting the result. However, the order of evaluation of sub-expressions is not defined. To force evaluation order, use a CASE construct.

Do not confuse Boolean operators with the Boolean predicate or Boolean data type, which can have only two values: true and false.

Logic

SQL uses a three-valued Boolean logic where the NULL represents "unknown."

  If a = and b = then …
a AND b = a OR b =

t

t

t

t

t

f

f

t

t

NULL

NULL

t

f

f

f

f

f

NULL

f

NULL

NULL

NULL

NULL

NULL

If a = … then NOT a =

t

f

f

t

NULL

NULL