Home / Blog / QUERY Function
Google Sheets · How-to · 2026

How to Use the QUERY Function in Google Sheets

QUERY is the most powerful function in Google Sheets — a mini SQL language that selects, filters, groups, and sorts your data in a single formula. Here's how to read and write one without the learning curve.

By the Quiriz Team · Published July 25, 2026 · 6 min read

The quick version: =QUERY(A1:C, "SELECT A, SUM(B) WHERE C = 'West' GROUP BY A", 1) reads your data, keeps only the West rows, and totals column B per value of column A — one formula instead of five. Here's how to build one.

The syntax

=QUERY(data, "query string", headers)

data is your range (include headers). query string is a SQL-like instruction in quotes. headers is how many header rows there are — usually 1.

The clauses you'll actually use

Putting it together

Total sales by region, biggest first, over $1,000:

=QUERY(A1:C, "SELECT B, SUM(C) WHERE C > 1000 GROUP BY B ORDER BY SUM(C) DESC", 1)

Common gotchas

💡 Tip: hide a parse error or an empty result by wrapping it: =IFERROR(QUERY(...), "").
💬 Skip the formula: QUERY is basically "ask your data a question" — which is exactly what the Quiriz add-in does in plain English. Instead of writing the SQL, type =QUIRIZ("total sales by region over $1,000, biggest first", "table") and it returns the same table.

QUERY, but in plain English

Quiriz turns a plain-English question into the answer — no SELECT/WHERE/GROUP BY to write. Ask right in your sheet with =QUIRIZ(). Free to start.

Try Quiriz free →

Frequently asked questions

What does the QUERY function do in Google Sheets?
QUERY runs a small SQL-like query over a range — selecting columns, filtering with WHERE, grouping with GROUP BY, and sorting with ORDER BY — and returns the result as a spilled table. It replaces stacking several formulas with one.
What is the syntax of QUERY?
=QUERY(data, query_string, headers). data is the range, query_string is the SQL-like instruction in quotes (using column letters like A, B or Col1, Col2), and headers is the number of header rows (usually 1).
How do I filter with WHERE in QUERY?
Add a WHERE clause: =QUERY(A1:C, "SELECT A, B WHERE C > 1000", 1) returns rows where column C is over 1000. Text values go in single quotes: WHERE B = 'West'.
Why do I get a QUERY parse error?
Usually the query string has a typo, uses the wrong column reference (letters like A vs Col1 depending on whether you gave a range or an array), or mixes up quotes. Text criteria need single quotes inside the double-quoted string.