IS NOT NULL
NOT NULL performs the exact opposite of the
IS NULL evaluation. It will drop all records in
the table whose column of evaluation has NULL values. This can be useful
if the data or analysis you are performing required every observation to
have data.
To demonstrate this on a query, let's modify the previous query that
returned records from the orders table whose freight information has
null values but ship_country is not null to now
return only customers
order_id, customer_id, ship_country, order_date
with missing freight details. The query would
look like this:
select order_id, customer_id, ship_country, order_date, freight
from orders
where freight IS NULL AND ship_country IS NOT NULL
The above results only contain values with valid region data.
Making use of NULL evaluations is an important
practice to validate information and analysis particularly if the
analysis is intended to drive a key decision. Null values happen for
many reasons and your ability to filter can allow you to have accurate
analysis and insights for decision making.
In the next section, we look at filtering text with the
LIKE Operator.