Beginner

19. NOT Operator

Learn how the NOT operator reverses a condition and helps exclude specific records.

📘 Lesson 19 of 728 ⏱ 7 min 🎯 Beginner

The NOT operator reverses the result of a condition. If a condition is true, NOT makes it false, and if the condition is false, NOT makes it true. It is commonly used when you want to exclude records that meet a particular condition.

Exclusion is a common business requirement. Analysts may need to exclude a department, region, product category, customer type, transaction status, or other group from their analysis.

A manager wants to see all employees except those working in the HR department. NOT can be used to exclude HR employees.

SQL
SELECT
    EmployeeName,
    Department
FROM Employees
WHERE NOT Department = 'HR';

NOT is useful for exclusion-based analysis, compliance checks, customer filtering, transaction analysis, and operational reporting.

  • NOT reverses a condition.
  • NOT can be used with WHERE.
  • NOT is useful for exclusions.
  • NOT can be combined with other logical operators.
  • NOT does not modify the original table.
What does NOT do in SQL?

NOT reverses the result of a logical condition.

Why would you use NOT?

NOT is useful when you need to exclude records that satisfy a particular condition.

Have you finished this lesson?

Introduction to SQL – All Lessons