ExcelFormulas logoExcelFormulas.
Ask AI
Google SheetsVerified QA Tested

QUERY.

Runs Google Visualization API SQL-like queries on data tables.

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])
Tip:Arguments wrapped in square brackets [like_this] are optional; all other arguments are required.

Formula arguments.

Every parameter accepted by the QUERY function is detailed below.

dataRequired

The cell range to query.

Example value: A1:C5
queryRequired

SQL-like query string enclosed in quotation marks.

Example value: "SELECT A, C WHERE C > 150"

Simple example.

Step-by-Step Scenario

High Value Orders Query

Extract products where sales exceed 150.

ProductRegionSalesQuery OutputOutput Sales
Widget AEast100——
Widget BWest300——
Widget CEast250——
Applied Formula
=QUERY(A1:C5, "SELECT A, C WHERE C > 150", 1)
Expected Result:Widget B

Evaluates QUERY over the sample table cells, placing the verified output in cell D2.

Formula generator.

Full Generator Wizard

Customize the argument fields below to generate a tailored QUERY formula ready to paste directly into your worksheet.

Generated FormulaReady to copy

Expected result behavior.

Returns "Widget B" based on sample evaluation criteria and active cell references.

Sample Output:Widget B
Output Type:Text String

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).
Compatibility Database

Platform & version compatibility.

Verified platform compatibility matrix based on actual spreadsheet calculation engine specifications.

Excel✕
No
Excel 365✕
No
Excel 2021✕
No
Excel 2019✕
No
Google Sheets✓
Supported
Microsoft Excel History & Version Availability

Not supported in Microsoft Excel. QUERY is a proprietary Google Sheets function that uses Google Visualization API SQL syntax.

Google Sheets Compatibility Notes

Native Google Sheets formula. Runs pseudo-SQL queries over sheet ranges for filtering, aggregation, and grouping.

Frequently asked questions.

Technical Q&A
Can 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).