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

ArgumentRequiredWhat it means
dataYesThe cell range to query.
queryYesThe query-language statement, in quotation marks or referenced from a cell.
headersNoThe number of header rows. If omitted or -1, Sheets guesses.

Examples

Select high scores

AB
1NameScore
2Ava84
3Ben92
4Cara88
=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.