Google Sheets function
QUERY function in Google Sheets
QUERY in Google Sheets runs a Google Visualization API Query Language statement across a cell range. It can select, filter, group, pivot, and order data. The optional headers argument tells Sheets how many header rows the input has; when omitted or set to -1, Sheets guesses.
Source: Google Docs Editors HelpLast verified Nov 5, 2026
Syntax
=QUERY(data, query, [headers])Arguments
| Argument | Required | What it means |
|---|---|---|
data | Yes | The cell range to query. |
query | Yes | The query-language statement, in quotation marks or referenced from a cell. |
headers | No | The number of header rows. If omitted or -1, Sheets guesses. |
Examples
Select high scores
| A | B | |
|---|---|---|
| 1 | Name | Score |
| 2 | Ava | 84 |
| 3 | Ben | 92 |
| 4 | Cara | 88 |
=QUERY(A1:B4,"select A, B where B >= 88",1)Result: Name | Score; Ben | 92; Cara | 88
The query keeps the header row, then returns the name and score columns for rows with scores of at least 88.
Common mistakes
Leaving a literal query outside quotation marks.
Put the query text in quotation marks or reference a cell containing the query.
Mixing data types within one column.
Keep each queried column consistent because minority data types are treated as null.