Guides/SQL NOT
📘
SQL Guide

SQL NOT

Exclude records by reversing a condition.

What & Why

The NOT operator is used to reverse the result of a condition — returning rows that do not match it. NOT is useful for exclusion rules: not churned, not bounced, not a deprecated feature, or not part of a campaign channel.

See how it works

Product wants features that have not been deprecated.

SELECT
  name,
  team,
  released_at
FROM product.features
WHERE deprecated_at IS NULL;

Syntax pattern

See explanation
WHERE NOT condition
WHERE column_name NOT IN ('value_a', 'value_b')
  • NOT reverses a boolean expression.
  • NOT IN excludes listed values but needs care with NULL.
  • IS NOT NULL is the correct form for present values.
Now You Try

Practice this concept hands-on

Sign up for a free account to run SQL against real datasets right here in the browser and get instant AI feedback. No credit card required.

Sign up free