# SQL: Working with NULL Values

This blog covers the handling of NULL values in SQL.

A NULL value is used in SQL when information for a column is either unknown or applicable. Note that a NULL value is different from the value zero.

Any arithmetic expression (unary, binary or relational) results in a NULL if any operand of that expression is itself a NULL value. In Boolean AND, OR, NOT, the behavior of NULL values is as follows [T — True, F — False, U — Unknown(NULL)]:

**AND:**If any one argument of AND is False then the result is False. Therefore, if U comes with T, it will always result into U because the output will depend on U. However, if U comes with F, it is sure that the result is F.

- T AND U = U

- U AND U = U

- F AND U = F

Note:*AND is a symmetric function, i.e., A AND B is same as B AND A*.**OR:**If any one argument of OR is T, the result is T. Therefore, U OR’d with T will have a result T. However, F OR’d with U will be U because the result will totally depend on the U.- T OR U = T

- U OR U = U

- F OR U = U**NOT**: NOT(U) = U

NOTE:

- Any NULL value in the argument of aggregate functions (AVG, SUM, MAX, MIN, COUNT) is eliminated before the respective Function is calculated. However, the aggregate function COUNT(*) handles all NULL values the same as non-NULL values.
- If the column contains only NULL values, the result of the function COUNT(DISTINCT column_name) is 0.