Ternary logic

As specified in the SQL standard, ternary logic, or three-valued logic (3VL), is a logic system with three truth values: TRUE, FALSE, and UNKNOWN. In Snowflake, UNKNOWN is represented by NULL. Ternary logic applies to the evaluation of Boolean expressions, as well as predicates, and affects the results of logical operations such as AND, OR, and NOT:

  • When used in expressions (for example, in a SELECT list), UNKNOWN results are returned as NULL values.
  • When used as a predicate (for example, in a WHERE clause), UNKNOWN results evaluate to FALSE.

Truth tables

This section describes the truth tables for the comparison and logical operators.

Comparison operators

If any operand for a comparison operator is NULL, the result is NULL. The comparison operators and functions are:

Logical operators

Given a BOOLEAN column C:

If C is:C AND NULL evaluates to:C OR NULL evaluates to:NOT C evaluates to:
TRUENULLTRUEFALSE