This tutorial explains how to use simple comparison operators in Google Sheets Query with clear, practical formula examples.
In the QUERY function of Google Sheets, there are seven simple comparison operators available:
< <= > >= = != <>
These operators are used to compare values in a column against a condition and filter rows accordingly.
In this guide, you’ll find basic, easy-to-follow examples showing how each comparison operator works in Google Sheets QUERY.
Before You Begin: Literals in Google Sheets Query
When using comparison operators in Google Sheets Query, you often need to compare values against literals (the values used in conditions).
The syntax for literals depends on the data type:
- Numbers → no quotes
- Text (strings) → must be enclosed in single or double quotes
- Dates → must be converted to a specific date format
For example, text values should be written like 'First', not First.
This tutorial does not go deep into literal handling. If you want a detailed explanation, see:
Examples of the Use of Literals in Query in Google Sheets
All Seven Simple Comparison Operators in Google Sheets Query
Sample Data
Student marks across three subjects and three terms (First, Second, and Third).

Below are seven QUERY formulas, each demonstrating one comparison operator.
1. Less Than (<) in Google Sheets Query
=QUERY(A1:E, "SELECT * WHERE C < 95", 1)
2. Greater Than (>) in Google Sheets Query
=QUERY(A1:E, "SELECT * WHERE D > 80", 1)

3. Less Than or Equal To (<=) in Google Sheets Query
=QUERY(A1:E, "SELECT * WHERE D <= 80", 1)
4. Greater Than or Equal To (>=) in Google Sheets Query
=QUERY(A1:E, "SELECT * WHERE E >= 80", 1)
5. Equal To (=) in Google Sheets Query
=QUERY(A1:E, "SELECT * WHERE B = 'First'", 1)
6. Not Equal To (<>) in Google Sheets Query
=QUERY(A1:E, "SELECT * WHERE B <> 'First'", 1)
7. Not Equal To (!=) in Google Sheets Query (Equivalent)
=QUERY(A1:E, "SELECT * WHERE B != 'First'", 1)
Both <> and != work identically and represent the not equal to comparison operator.
Comparing Against Empty Cells (NULL)
In Google Sheets QUERY, NULL values cannot be compared using = or !=.
Instead, use:
=QUERY(A1:E, "SELECT * WHERE B IS NOT NULL", 1)
Or:
=QUERY(A1:E, "SELECT * WHERE B IS NULL", 1)
This is essential when working with incomplete datasets.
Using Multiple Comparison Operators
To combine multiple conditions—either in the same column or across different columns—use logical operators such as AND, OR, and NOT in the WHERE clause.
For a complete and structured explanation of logical conditions, comparison operators, and condition-building patterns, refer to the hub:
WHERE Clause in Google Sheets QUERY: Logical Conditions Explained
Complex Comparison Operators in Google Sheets Query
In addition to simple comparison operators, Google Sheets QUERY also supports string-based (complex) comparison operators.
These are primarily used for text matching:
CONTAINSMATCHESSTARTS WITHENDS WITHLIKE
These operators are explained in detail here:
String Matching in QUERY
Note: Some of these operators can also be used with numbers, but their primary purpose is string comparison.
Conclusion
The simple comparison operators in Google Sheets Query—<, <=, >, >=, =, !=, and <>—form the foundation of filtering data with the QUERY function.
Key takeaways:
- Use simple operators for numeric, text, and date comparisons
- Handle NULL values with
IS NULLorIS NOT NULL - Combine conditions using logical operators
- Use complex operators when pattern matching is required
With these fundamentals, you can confidently build powerful QUERY filters in Google Sheets.






















How can I compare the dates?
Hi, Daniel R,
Please see to this.
How to Use Date Criteria in Query Function in Google Sheets.