How to use QUERY in Google Sheets

Updated · DeskHowTo

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.

Jump to

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

  1. Click an empty cell for the output spill range.
  2. Enter =QUERY(A1:E200,"select A, B, E where E >= 100",1).
  3. Confirm headers appear once and data spills below.

Sort and group

  1. Add order by E desc before the closing quote.
  2. Aggregate: select A, sum(E) where E is not null group by A label sum(E) 'Total'.
  3. Keep output cells clear — QUERY needs room to expand.

Dates and text criteria

  1. Text equals: where B = 'East' (single quotes inside the query string).
  2. Dates often need where C >= date '2026-01-01'.
  3. Use Col1, Col2 instead of letters when the range is a formula result.

QUERY vs FILTER vs pivot

ToolBest for
QUERYSQL-like select/aggregate in one formula
FILTERSimple conditional spill arrays
Pivot tableInteractive 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 0 or 1).
  • 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.

Sources checked: Google Help: QUERY function. Verified October 2026.