You will use the WHERE clause in Google Sheets QUERY in almost every practical formula you build. At a minimum, it is commonly used to exclude empty rows—especially when working with open ranges—making it a foundational element of most QUERY solutions.
Whether you are applying simple comparisons or building complex logical rules, the WHERE clause controls how conditions are structured, combined, and evaluated to determine which rows appear in the result.
This hub explains logical conditions in the WHERE clause in Google Sheets QUERY, including how to use AND, OR, and NOT, apply comparison operators, exclude values, and build scalable condition logic. Each section links to a focused tutorial that solves a specific WHERE-clause logic problem.
Scope note: This hub focuses on condition structure and logic in the WHERE clause.
For text-specific filtering operators such as CONTAINS, STARTS WITH, ENDS WITH, LIKE, and MATCHES, see String Matching in Google Sheets QUERY.
Use this page as a central reference whenever you work with QUERY WHERE logic in Google Sheets.
What Is the WHERE Clause in Google Sheets QUERY?
The WHERE clause in Google Sheets QUERY comes after the SELECT clause and is optional. It works similarly to the SQL WHERE clause and filters rows based on logical conditions applied to one or more columns.
You can use the WHERE clause in Google Sheets QUERY to:
- Filter rows based on values such as text, dates, times, blanks, or Boolean TRUE/FALSE
- Apply logical rules across multiple columns
- Combine conditions using AND, OR, and NOT
- Exclude rows using not-equal logic
- Build dynamic and scalable QUERY formulas
A solid understanding of the WHERE clause in Google Sheets QUERY helps keep formulas readable, flexible, and easy to maintain.
Logical Conditions in the WHERE Clause (AND, OR, NOT)
When filtering data, logical operators define how multiple conditions are evaluated inside the WHERE clause in Google Sheets QUERY.
- AND → all conditions must be true
- OR → any condition can be true
- NOT → explicitly excludes values or conditions
These operators are simple but often misunderstood when used together in a QUERY formula, especially without proper use of parentheses to control evaluation order.
Start with these tutorials:
- How to Use AND, OR, and NOT in Google Sheets QUERY
- How to Apply Multiple OR Conditions in Google Sheets QUERY
- How to Handle Several OR Columns in QUERY in Google Sheets
Each guide explains how logical conditions behave inside the WHERE clause and how to avoid incorrect or unexpected results.
Example QUERY with Combined Logical Conditions
Assume you have items in column A, region in column B, sales date in column C, and status in column D.
=QUERY(A1:D,
"select *
where (Col2 = 'North' or Col2 = 'East')
and Col3 >= date '2026-01-01'
and Col4 <> 'Rejected'",
1)
Explanation:
This formula returns all items from the North or East regions with a sales date on or after January 1, 2026, excluding rows where the status is Rejected.
Simplifying WHERE Clause Logic in Google Sheets QUERY
As QUERY formulas grow, the WHERE clause in Google Sheets QUERY can become long and difficult to manage. Simplifying condition logic improves readability and makes formulas easier to extend.
Learn proven structuring techniques here:
- How to Simplify Conditions in Multiple Columns in Google Sheets QUERY
- The Purpose of WHERE 1=1 in Google Sheets Query
These techniques are especially useful when building QUERY formulas dynamically or when conditions are added incrementally.
Comparison Operators in the WHERE Clause
The WHERE clause in Google Sheets QUERY supports several comparison operators beyond simple equality.
Common operators include:
=(equal to)<>(not equal to)>,<,>=,<=(numeric and date comparisons)
To understand how these operators behave in real formulas, see:
- Simple Comparison Operators in Google Sheets Query
- How to Use Not Equal to in Query in Google Sheets
These tutorials cover numeric, date-based, and text comparisons, along with common mistakes.
Advanced Condition Handling in the WHERE Clause
Some filtering scenarios require more than basic comparisons, such as dynamically selecting filter columns or filtering values based on a list of conditions. The WHERE clause in Google Sheets QUERY can be extended using logical workarounds and dynamic techniques.
Explore advanced condition-handling methods here:
- MATCH Function in Query Where Clause in Google Sheets
- The Alternative to SQL IN Operator in Google Sheets Query
These approaches help model complex logic when QUERY lacks direct SQL features.
How to Use This WHERE Clause Hub
Use this hub based on your goal:
- New to QUERY?
Start with logical operators in the WHERE clause. - Results not matching expectations?
Review comparison operators and NOT logic. - Building complex or dynamic QUERY formulas?
Focus on condition simplification and structuring techniques.
This page is designed as a long-term reference for mastering the WHERE clause in Google Sheets QUERY and understanding how logical conditions actually work.
Final Note
To filter data effectively before applying aggregation or pivoting, you should master the WHERE clause. Proper use of the WHERE clause resolves most common QUERY-related issues.
Bookmark this hub and return to it whenever your QUERY output does not behave as expected.





















