How to use QUERY in Google Sheets
In Google Sheets (verified 2026-10-24), use =QUERY(A1:D100,"select A, C where D > 100 order by C desc",1) to return matching rows. The last argument 1 means the range has one header row.
Column letters inside the query string refer to positions in the range you passed, not always the whole sheet.
Applies to spreadsheet.google.com on desktop browsers. QUERY is not available as an Excel worksheet function (use filters, FILTER, or Power Query there).
Build a basic QUERY
Select and where
- Click an empty cell for the output spill range.
- Enter
=QUERY(A1:E200,"select A, B, E where E >= 100",1). - Confirm headers appear once and data spills below.
Sort and group
- Add
order by E descbefore the closing quote. - Aggregate:
select A, sum(E) where E is not null group by A label sum(E) 'Total'. - Keep output cells clear — QUERY needs room to expand.
Dates and text criteria
- Text equals:
where B = 'East'(single quotes inside the query string). - Dates often need
where C >= date '2026-01-01'. - Use
Col1,Col2instead of letters when the range is a formula result.
QUERY vs FILTER vs pivot
| Tool | Best for |
|---|---|
| QUERY | SQL-like select/aggregate in one formula |
| FILTER | Simple conditional spill arrays |
| Pivot table | Interactive exploration — see Sheets pivot |
Our take: QUERY shines for dashboard extracts; teach teammates the string carefully — quotes nest easily.
If it fails
- #VALUE! / parse error: mismatched quotes or reserved words — simplify the clause.
- Empty output: WHERE too strict, or header count argument wrong (try
0or1). - Wrong columns: letters are relative to the range argument.
- #REF! spill: clear blocking cells under the formula.
Frequently asked questions
What does QUERY do in Google Sheets?
It runs a SQL-like query over a range and returns a table.
Is QUERY available in Excel?
Not as the same worksheet function — use FILTER, pivots or Power Query.
Why use Col1 instead of A?
When querying a formula output that lacks sheet letters, ColN is required.
Can QUERY join two sheets?
Not a real SQL join — use helper columns or IMPORTRANGE + QUERY.
Does QUERY update live?
Yes — it recalculates when source cells change.