Nested Boolean Operators: Quick Tip

Posted January 18, 2019 by Jim Knicely, Vertica Principal Solution Architect

white cloud in vault type room representing cloud computing
Vertica supports the following Boolean operators:

• AND

• OR

• NOT

Example: dbadmin=> SELECT 1<2 OR 1>2 "Boolean Result"; Boolean Result ---------------- t (1 row) dbadmin=> SELECT NOT FALSE AND TRUE "Boolean Result"; Boolean Result ---------------- t (1 row) dbadmin=> SELECT NOT NOT NOT FALSE OR FALSE "Boolean Result"; Boolean Result ---------------- t (1 row) To nest Boolean operators, use parenthesis! dbadmin=> SELECT (TRUE OR FALSE) AND TRUE "Boolean Result"; Boolean Result ---------------- t (1 row) dbadmin=> SELECT NOT ((TRUE OR FALSE) OR FALSE) AND TRUE "Boolean Result"; Boolean Result ---------------- f (1 row) Helpful Link:

https://www.vertica.com/docs/latest/HTML/Content/Authoring/SQLReferenceManual/LanguageElements/Operators/BooleanOperators.htm

Have fun!