How it works.
QUERY is the premier data transformation function in Google Sheets, enabling SQL statements (SELECT, WHERE, GROUP BY, ORDER BY, LIMIT) directly over spreadsheet tables.
Formula syntax.
Standard Excel Notation=QUERY(data, query, [headers])[like_this] are optional; all other arguments are required.Formula arguments.
Every parameter accepted by the QUERY function is detailed below.
The cell range to query.
Example value:A1:C5SQL-like query string enclosed in quotation marks.
Example value:"SELECT A, C WHERE C > 150"Simple example.
Step-by-Step ScenarioHigh Value Orders Query
Extract products where sales exceed 150.
| Product | Region | Sales | Query Output | Output Sales |
|---|---|---|---|---|
| Widget A | East | 100 | — | — |
| Widget B | West | 300 | — | — |
| Widget C | East | 250 | — | — |
=QUERY(A1:C5, "SELECT A, C WHERE C > 150", 1)Evaluates QUERY over the sample table cells, placing the verified output in cell D2.
Formula generator.
Full Generator WizardCustomize the argument fields below to generate a tailored QUERY formula ready to paste directly into your worksheet.
=QUERY()Expected result behavior.
Returns "Widget B" based on sample evaluation criteria and active cell references.
Best Practices
- Use uppercase keywords like SELECT and WHERE for readability.
Common Mistakes
- Google Sheets QUERY requires data in each column to be consistently typed (avoid mixing numbers and text).
Platform & version compatibility.
Verified platform compatibility matrix based on actual spreadsheet calculation engine specifications.
For Microsoft Excel, use the FILTER function (Excel 365 / 2021), SUMIFS/COUNTIFS, or Power Query (Get & Transform).
Not supported in Microsoft Excel. QUERY is a proprietary Google Sheets function that uses Google Visualization API SQL syntax.
Native Google Sheets formula. Runs pseudo-SQL queries over sheet ranges for filtering, aggregation, and grouping.
Frequently asked questions.
Technical Q&ACan I use QUERY across different worksheets in Excel?↓
Yes. You can reference cells located on other sheets by including the sheet name followed by an exclamation mark, for example: =QUERY(Sheet2!A2:A10). If the sheet name contains spaces, enclose it in single quotes: ='Q1 Report'!A2:A10.
What is the most common reason for errors in QUERY?↓
Google Sheets QUERY requires data in each column to be consistently typed (avoid mixing numbers and text).
Does QUERY work in Microsoft Excel?↓
No. QUERY is a proprietary Google Sheets function and is not supported in Microsoft Excel. Recommended Excel alternative: For Microsoft Excel, use the FILTER function (Excel 365 / 2021), SUMIFS/COUNTIFS, or Power Query (Get & Transform).