Logical functions

SQL Function Description

boolean1 or boolean2

Returns TRUE if boolean1 is TRUE or boolean2 is TRUE.

Supports three-valued logic. For example:

SELECT c1, c2, c1 OR c2 AS or_result
FROM (VALUES (TRUE,
              CAST(UNKNOWN AS BOOLEAN)))
              AS t(c1,c2);
c1 c2 or_result

TRUE

<NULL>

TRUE

boolean1 and boolean2

Returns TRUE if boolean1 and boolean2 are both TRUE.

Supports three-valued logic. For example:

SELECT c1, c2, c1 AND c2 AS and_result
FROM (VALUES (TRUE,
              CAST(UNKNOWN AS BOOLEAN)))
              AS t(c1,c2);
c1 c2 and_result

TRUE

<NULL>

<NULL>

NOT boolean

Returns TRUE if boolean is FALSE; returns FALSE if boolean is TRUE; returns UNKNOWN if boolean is UNKNOWN.

boolean IS FALSE

Returns TRUE if boolean is FALSE; returns FALSE if boolean is TRUE or UNKNOWN.

boolean IS NOT FALSE

Returns TRUE if boolean is TRUE or UNKNOWN; returns FALSE if boolean is FALSE.

boolean IS TRUE

Returns TRUE if boolean is TRUE; returns FALSE if boolean is FALSE or UNKNOWN.

boolean IS NOT TRUE

Returns TRUE if boolean is FALSE or UNKNOWN; returns FALSE if boolean is TRUE.

boolean IS UNKNOWN

Returns TRUE if boolean is UNKNOWN; returns FALSE if boolean is TRUE or FALSE.

boolean IS NOT UNKNOWN

Returns TRUE if boolean is TRUE or FALSE; returns FALSE if boolean is UNKNOWN.