New: ready-to-use spreadsheet templatesExplore the collection  →
LOOKUP & REFERENCE · GOOGLE SHEETS

QUERY
filter, group and summarize a range with query language.

Use QUERY to summarize sales by region. This guide shows the exact structure, a working example and the mistakes most likely to break it.

JosephineVerified by JosephineReviewed July 25, 2026
THE FORMULA=QUERY(data, query, [headers])
A

datasource table

B

queryquery statement in quotes

C

headersnumber of heading rows

TRY IT YOURSELF

Change the sheet.
Watch the answer update.

Edit any highlighted cell below. The example recalculates immediately.

LIVE PLAYGROUND=QUERY(A1:C20,"select A,sum(C) group by A",1)
fx=QUERY(A1:C20,"select A,sum(C) group by A",1)
A · IDB · TEAMC · AMOUNT
2
3
4
5
RESULT1 matching rowsUpdates live

Try changing a value above. This example runs entirely in your browser.

IN PLAIN ENGLISH

How the formula
thinks.

  1. 01

    datasource table

  2. 02

    queryquery statement in quotes

  3. 03

    headersnumber of heading rows

COMMON FIXES

When QUERY
doesn’t behave.

WRONG RESULT

Wrong result

Check that every range starts and ends on the same rows, and that numbers are stored as numbers.

FORMULA PARSE ERROR

Formula parse error

Check commas, quotation marks and closing parentheses. Your locale may use semicolons instead of commas.

UNEXPECTED BLANKS

Unexpected blanks

Test the source cells for hidden spaces, empty strings and inconsistent data types.

fxNeed help with QUERY?Fix my formula →