How to Use Not Equal to in Query in Google Sheets

Published on

There are two simple and one advanced comparison methods to apply not equal to in Query in Google Sheets.

You can use any of these methods to filter data, depending on the data type of the column—text, numbers, or dates.

This tutorial explains how to use not equal to in the Google Sheets QUERY function using:

  • !=
  • <>
  • NOT MATCHES (regular expression–based)

This guide is part of the WHERE Clause in Google Sheets QUERY: Logical Conditions Explained hub, which covers all logical operators, comparisons, and condition-building patterns used in QUERY statements.

Not Equal to in Query Function in Google Sheets

To demonstrate the different not equal to operators, let’s use a sample dataset containing:

  • Column A → Text
  • Column B → Numbers
  • Column C → Dates

This allows us to test how not equal to in Query in Google Sheets behaves across different data types.

Sample data table used for not equal to in Google Sheets QUERY examples

1. Using != Operator in Query Function

The != operator is one of the simplest ways to apply a not equal to condition in QUERY.

Formula #1: != in a text column

Filter rows where Column A does not equal the value in cell E1:

=QUERY(A1:C,"SELECT A,B,C WHERE A != '"&E1&"' AND A IS NOT NULL")

Tip: To avoid returning blank rows when using not equal to in Google Sheets QUERY, add AND <column> IS NOT NULL for the column being evaluated (such as A, B, or C).

Not equal to in Google Sheets QUERY using comparison operator with text criteria

Hardcoded criterion example:

=QUERY(A1:C,"SELECT A,B,C WHERE A != 'AB10025YX 2' AND A IS NOT NULL")

Formula #2: != in a numeric column

Filter rows where Column B is not equal to the value in E1:

=QUERY(A1:C,"SELECT A,B,C WHERE B != "&E1&" AND A IS NOT NULL")

Hardcoded numeric criterion:

=QUERY(A1:C,"SELECT A,B,C WHERE B != 1 AND A IS NOT NULL")

Formula #3: != in a date column

Using dates in QUERY requires special handling. Dates must be converted to a specific string format.

=QUERY(
  A1:C,
  "SELECT A,B,C WHERE C != date '"&TEXT(E1,"yyyy-mm-dd")&"' AND A IS NOT NULL"
)

Hardcoded date criterion:

=QUERY(A1:C,"SELECT A,B,C WHERE C != date '2018-01-25' AND A IS NOT NULL")

⚠️ Dates cannot be used directly in QUERY unless they are formatted as strings using yyyy-mm-dd.

2. Using the <> Operator in Query Function

The <> operator works exactly the same as != in the Google Sheets QUERY language.

You can replace != with <> in all the above formulas without changing the logic or results.

3. Using NOT MATCHES for Not Equal to in Google Sheets Query

The MATCHES operator uses regular expressions, making it more powerful and flexible—especially for partial matches.

To apply not equal to, prefix it with the NOT logical operator.

Formula #1: NOT MATCHES in a text column

=QUERY(A1:C,"SELECT A,B,C WHERE NOT A MATCHES '"&E1&"' AND A IS NOT NULL")

Hardcoded text criterion:

=QUERY(A1:C,"SELECT A,B,C WHERE NOT A MATCHES 'AB10025YX 3' AND A IS NOT NULL")

Formula #2: NOT MATCHES in a numeric column

Using a numeric criterion from E1:

=QUERY(A1:C,"SELECT A,B,C WHERE NOT B MATCHES "&E1&" AND A IS NOT NULL")

Hardcoded numeric value:

=QUERY(A1:C,"SELECT A,B,C WHERE NOT B MATCHES 1 AND A IS NOT NULL")

Formula #3: NOT MATCHES in a date column

=QUERY(
  A1:C,
  "SELECT A,B,C WHERE NOT C MATCHES date '"&TEXT(E1,"yyyy-mm-dd")&"' AND A IS NOT NULL"
)
Not equal to in Google Sheets QUERY using NOT MATCHES with date criteria

Hardcoded date:

=QUERY(A1:C,"SELECT A,B,C WHERE NOT C MATCHES date '2018-01-25' AND A IS NOT NULL")

Conclusion: Not Equal to in Query in Google Sheets

To summarize:

  • Use != or <> for simple not equal to comparisons
  • Use NOT MATCHES when you need pattern-based or flexible matching
  • Dates must always be converted to QUERY-compatible strings
  • The NOT logical operator must precede the column reference, not the value

These methods cover all practical ways to apply not equal to in Query in Google Sheets without resorting to multiple OR conditions.

For a complete understanding of logical conditions in QUERY, see the hub:
WHERE Clause in Google Sheets QUERY: Logical Conditions Explained

For advanced string filtering, refer to:
String Matching in QUERY

Prashanth KV
Prashanth KV
Your Trusted Google Sheets and Excel Expert Prashanth KV is a Diamond Product Expert in Google Sheets, officially recognized by Google for his contributions to the Docs Editors Help Community and featured in the Google Product Experts Directory. Explore his blog to learn advanced formulas, automation tips, and problem-solving techniques to elevate your spreadsheet skills.

Top Discussions

More like this

Pivot Table Formatting, Output & Special Behavior in Google Sheets

Pivot Tables in Google Sheets are powerful—but they can get tricky once you move...

Pivot Table Calculations & Advanced Metrics in Google Sheets

When it comes to built-in tools for data analysis and visualization in Google Sheets,...

Google Sheets Pivot Table Tutorial: Basics, Setup, and Date Grouping

The easiest way to summarize, analyze, and report data in Google Sheets is by...

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.