Querying Data With QUERY
Select, filter, and group data using SQL-like syntax in Sheets.
What QUERY Does
Google Sheets has one function that feels like a tiny database language: QUERY. It lets you select, filter, and summarize data using a syntax very close to SQL.
Instead of stacking FILTER, SORT, and SUMIF together, you write one readable instruction. For example, show me only the East region rows, sorted by sales becomes a single formula.
QUERY is unique to Google Sheets. Excel does not have it, so this whole lesson is Sheets-only.
The Basic Syntax
QUERY takes three parts:
- data the range to read, like
A1:D100 - query a text string of instructions, in quotes
- headers an optional number telling QUERY how many header rows there are
The query string is where the magic lives. It always goes inside double quotes.
=QUERY(A1:D100, "SELECT A, B", 1)