Text values in WHERE must be wrapped in single quotes: WHERE C = 'Scotland Yard'. Numbers and dates do not use quotes. Missing single quotes around text is the most common WHERE error.
QUERY WHERE Clause in Google Sheets
Learn how to use the QUERY WHERE clause in Google Sheets to filter rows by text, numbers, dates, and multiple conditions. Examples and common mistakes.
Sheets Bootcamp
February 28, 2026 Ā· Updated August 7, 2026
Table of Contents
The QUERY WHERE clause in Google Sheets filters rows based on conditions you define inside the query string. It works like a row-level filter built into the QUERY function, you set the rules, and WHERE returns only the rows that match. Weāll cover text filters, numeric comparisons, date handling, multiple conditions with AND/OR, and text matching with contains.
In This Guide
- WHERE Clause Syntax
- How to Filter Rows with WHERE: Step-by-Step
- Filter by Text Value
- Filter by Number
- Combine Conditions with AND / OR
- Filter with Contains, Starts With, Ends With
- Filter by Date
- Common WHERE Mistakes
- Tips
- Related Google Sheets Tutorials
- FAQ
WHERE Clause Syntax
WHERE goes inside the query string, after SELECT:
=QUERY(data, "SELECT columns WHERE condition") The condition compares a column to a value using an operator:
| Operator | Meaning | Example |
|---|---|---|
= | Equals | WHERE C = 'Scotland Yard' |
!= | Not equal | WHERE C != 'Whitehall' |
> | Greater than | WHERE F > 400 |
< | Less than | WHERE E < 10 |
>= | Greater than or equal | WHERE F >= 500 |
<= | Less than or equal | WHERE E <= 15 |
Important
How to Filter Rows with WHERE: Step-by-Step
Weāll use the same sales records table from the QUERY pillar guide. The data is in A1:G11 with 10 transactions.
Sample Data
| A | B | C | D | E | F | G | |
|---|---|---|---|---|---|---|---|
| 1 | Date | Salesperson | Region | Product | Units | Revenue | Commission |
| 2 | 1/5/2026 | Sherlock Holmes | Baker Street | Listening Device | 12 | $239.88 | $24.00 |
| 3 | 1/7/2026 | Irene Adler | Scotland Yard | Forensic Chemistry Set | 8 | $360.00 | $36.00 |
| 4 | 1/8/2026 | Inspector Lestrade | Baker Street | Pocket Watch | 15 | $525.00 | $52.50 |
| 5 | 1/10/2026 | Sherlock Holmes | Baker Street | Field Binoculars | 5 | $325.00 | $32.50 |
| 6 | 1/12/2026 | Mycroft Holmes | Scotland Yard | Cipher Decoder | 20 | $570.00 | $57.00 |
| 7 | 1/14/2026 | Irene Adler | Whitehall | Magnifying Glass | 25 | $624.75 | $62.50 |
| 8 | 1/15/2026 | Inspector Lestrade | Scotland Yard | Listening Device | 10 | $199.90 | $20.00 |
| 9 | 1/18/2026 | Sherlock Holmes | Baker Street | Disguise Kit | 3 | $269.97 | $27.00 |
| 10 | 1/20/2026 | Mycroft Holmes | Whitehall | Brass Telescope | 8 | $336.00 | $33.60 |
| 11 | 1/22/2026 | Irene Adler | Scotland Yard | Lockpick Set | 6 | $330.00 | $33.00 |

Review your data range
Your data lives in A1:G11. Row 1 is the header. Columns are Date (A), Salesperson (B), Region (C), Product (D), Units (E), Revenue (F), and Commission (G).
Write a WHERE clause with a text condition
Select an empty cell and enter:
=QUERY(A1:G11, "SELECT * WHERE C = 'Scotland Yard'") This returns all seven columns, but only rows where Region (column C) equals āScotland Yardā. The result is 4 rows: Irene Adlerās Forensic Chemistry Set, Mycroft Holmesās Cipher Decoder, Inspector Lestradeās Listening Device, and Irene Adlerās Lockpick Set.

Write a WHERE clause with a numeric condition
Enter a new formula:
=QUERY(A1:G11, "SELECT B, D, F WHERE F > 400") This returns rows where Revenue exceeds $400, showing only the Salesperson, Product, and Revenue columns. Three rows qualify: Inspector Lestradeās Pocket Watch ($525.00), Mycroft Holmesās Cipher Decoder ($570.00), and Irene Adlerās Magnifying Glass ($624.75).

Combine multiple conditions with AND
Enter:
=QUERY(A1:G11, "SELECT B, D, F WHERE C = 'Baker Street' AND F > 300") This returns rows where the region is Baker Street AND revenue exceeds $300. Two rows match: Inspector Lestradeās Pocket Watch ($525.00) and Sherlock Holmesās Field Binoculars ($325.00).

Tip
QUERY results spill into adjacent cells. Make sure the cells below and to the right of your formula are empty, or you get a #REF! error.
Filter by Text Value
Exact text matches use the = operator with single quotes:
=QUERY(A1:G11, "SELECT B, D, F WHERE B = 'Sherlock Holmes'") This returns Sherlock Holmesās 4 transactions from the 10-row dataset. The text match is case-sensitive, 'sherlock holmes' returns nothing.
To exclude a specific value, use !=:
=QUERY(A1:G11, "SELECT * WHERE C != 'Whitehall'") This returns all rows except the two Whitehall transactions.
Note
QUERY WHERE is case-sensitive for text comparisons. If your data has inconsistent casing, use the lower() function inside the query: WHERE lower(B) = 'sherlock holmes'. This converts column B values to lowercase before comparing.
Filter by Number
Numeric comparisons do not use quotes around the value:
=QUERY(A1:G11, "SELECT B, D, E WHERE E >= 15") This returns rows where Units (column E) is 15 or more. Three rows qualify: Inspector Lestradeās 15 Pocket Watches, Mycroft Holmesās 20 Cipher Decoders, and Irene Adlerās 25 Magnifying Glasses.
To filter a range of values, combine two conditions:
=QUERY(A1:G11, "SELECT B, D, F WHERE F >= 300 AND F <= 500") This returns transactions between $300 and $500 in revenue.
Combine Conditions with AND / OR
AND (all conditions must be true)
=QUERY(A1:G11, "SELECT B, D, F WHERE C = 'Scotland Yard' AND F > 400") Returns Scotland Yard transactions with revenue over $400. One row matches: Mycroft Holmesās Cipher Decoder ($570.00).
OR (any condition can be true)
=QUERY(A1:G11, "SELECT B, C, F WHERE C = 'Whitehall' OR C = 'Scotland Yard'") Returns all transactions from either Whitehall or Scotland Yard. Six rows match.
Combining AND and OR
Use parentheses to group conditions:
=QUERY(A1:G11, "SELECT B, C, F WHERE (C = 'Baker Street' OR C = 'Scotland Yard') AND F > 400") This returns rows from Baker Street or Scotland Yard where revenue exceeds $400. Two rows match: Inspector Lestradeās Pocket Watch ($525.00) from Baker Street and Mycroft Holmesās Cipher Decoder ($570.00) from Scotland Yard.
The logic follows the same patterns as IF with AND and OR, AND narrows results, OR broadens them.
Warning
Without parentheses, AND takes precedence over OR. WHERE C = 'Baker Street' OR C = 'Scotland Yard' AND F > 400 is interpreted as WHERE C = 'Baker Street' OR (C = 'Scotland Yard' AND F > 400), which is not the same thing. Always use parentheses when mixing AND and OR.
Filter with Contains, Starts With, Ends With
QUERY WHERE supports partial text matching with three keywords:
| Keyword | Meaning | Example |
|---|---|---|
contains | Text includes the value anywhere | WHERE B contains 'Holmes' |
starts with | Text begins with the value | WHERE D starts with 'E' |
ends with | Text ends with the value | WHERE D ends with 's' |
Contains Example
=QUERY(A1:G11, "SELECT B, D, F WHERE B contains 'Holmes'") This returns every row where the Salesperson name includes āHolmes.ā Five rows match, all transactions by Sherlock or Mycroft Holmes.

Starts With Example
=QUERY(A1:G11, "SELECT B, D WHERE D starts with 'F'") This returns products that start with the letter F: Forensic Chemistry Set and Field Binoculars.
Note
contains, starts with, and ends with are all case-sensitive. To match regardless of case, wrap the column in lower(): WHERE lower(B) contains 'holmes'.
Filter by Date
Dates in QUERY WHERE need the date keyword and YYYY-MM-DD format:
=QUERY(A1:G11, "SELECT B, A, F WHERE A > date '2026-01-15'") This returns transactions after January 15, 2026. Three rows from the 10-row dataset qualify: Sherlock Holmes 1/18/2026 ($269.97), Mycroft Holmes 1/20/2026 ($336.00), and Irene Adler 1/22/2026 ($330.00). Inspector Lestradeās 1/15 sale does not make the cut, because January 15 is not after January 15.

Important
Without the date keyword, QUERY treats the value as text and returns the header row with zero data rows, no error. Always write date '2026-01-15', not '2026-01-15' or '1/15/2026'.
Common WHERE Mistakes
Missing single quotes around text values
WHERE C = Scotland Yard breaks because QUERY interprets Scotland Yard as a column name. The fix: WHERE C = 'Scotland Yard' with single quotes.
Using double quotes inside the query string
The query string is already inside double quotes, so using double quotes for text values causes a syntax error. Use single quotes for text values inside WHERE.
Case mismatch on text comparisons
WHERE B = 'sherlock holmes' returns no results when the data contains āSherlock Holmes.ā QUERY WHERE is case-sensitive. Either match the exact case or use lower(): WHERE lower(B) = 'sherlock holmes'.
Forgetting the date keyword
WHERE A > '2026-01-15' compares dates as text strings, which gives wrong results. Use WHERE A > date '2026-01-15' with the date keyword.
Wrong column letter
Column letters in the query string must match the columns in your data range. If your range is A1:G11, then A is the first column. If your range starts at C1, then C is the first column in the query. Double-check that you are referencing the correct column.
Tips
1. Start with SELECT * to see all columns. Once you confirm your WHERE condition returns the right rows, narrow the SELECT to the columns you need.
2. Use cell references for dynamic filtering. Instead of hardcoding a value, reference a cell: =QUERY(A1:G11, "SELECT * WHERE C = '"&I1&"'"). This lets you change the filter by editing cell I1. The concatenation ('"&I1&"') inserts single quotes around the cell value.
3. Chain WHERE with other clauses. WHERE combines with SELECT, GROUP BY, ORDER BY, and LIMIT. For example: "SELECT C, SUM(F) WHERE F > 200 GROUP BY C" filters first, then groups. WHERE always runs before GROUP BY.
Tip
For filtering without the query language syntax, the FILTER function is faster to write for basic row filtering. Reserve QUERY WHERE for when you also need sorting, grouping, or column selection in the same formula.
Related Google Sheets Tutorials
- QUERY Function: Complete Guide: covers all QUERY clauses with syntax and examples
- QUERY SELECT: choose specific columns and reorder the output
- QUERY GROUP BY: summarize and aggregate data with SUM, COUNT, and AVG
- IF with AND / OR: same AND/OR logic applied to IF statements
Frequently Asked Questions
How do you filter rows with QUERY WHERE in Google Sheets?
Is QUERY WHERE case-sensitive in Google Sheets?
Can you use QUERY WHERE with multiple conditions?
How do you filter text that contains a word in QUERY?
How do you use QUERY WHERE with dates?
You've googled this formula before. Probably more than once.
Basic Training is a free course inside a real Google Sheet that grades every formula the moment you press Enter. 7 lessons, about 40 minutes, and this loop ends.
Try the Sheet That Grades YouFree. No spam, ever.