# How to use the QUERY function in Google Sheets

Give QUERY a range, a query in quotes and the number of header rows: `=QUERY(A1:F13,"select B, D, F where F > 2000",1)` returns the rep, product and revenue of every order over $2,000.

**Google Sheets:** `=QUERY(A1:F13,"select B, D, F where F > 2000",1)`

**Excel:** Excel has no QUERY function. In Excel 2024 or Microsoft 365, FILTER picks the rows and CHOOSECOLS the columns: `=CHOOSECOLS(FILTER(A2:F13,F2:F13>2000),2,4,6)`. Add the header row on top with VSTACK if you need it.

## Example

Sample data (row 1 is the header):

| A | B | C | D | E | F |
| --- | --- | --- | --- | --- | --- |
| Date | Rep | Region | Product | Units | Revenue |
| 2026-07-03 | Ana Ruiz | East | Widget | 40 | 2080 |
| 2026-07-06 | Raj Patel | West | Gadget | 25 | 2225 |
| 2026-07-10 | Lee Chen | East | Gizmo | 12 | 1740 |
| 2026-07-14 | Ana Ruiz | North | Gadget | 30 | 2670 |
| 2026-07-17 | Kim Ortiz | West | Widget | 55 | 2860 |
| 2026-07-21 | Raj Patel | East | Widget Pro | 18 | 1422 |
| 2026-07-24 | Lee Chen | South | Gadget | 22 | 1958 |
| 2026-07-29 | Kim Ortiz | East | Gizmo | 9 | 1305 |
| 2026-08-04 | Mo Diaz | North | Gizmo | 14 | 2030 |
| 2026-08-07 | Raj Patel | South | Widget | 20 | 1040 |
| 2026-08-12 | Kim Ortiz | North | Gadget | 16 | 1424 |
| 2026-08-18 | Mo Diaz | East | Gizmo Mini | 28 | 1092 |

Formula in H1: `=QUERY(A1:F13,"select B, D, F where F > 2000",1)`

Result (spills 6 × 3): Rep, Product, Revenue; Ana Ruiz, Widget, $2,080; Raj Patel, Gadget, $2,225; Ana Ruiz, Gadget, $2,670; Kim Ortiz, Widget, $2,860; Mo Diaz, Gizmo, $2,030

## How it works

The query is written in Google's query language, as text. `select B, D, F` picks the columns by their letters in the range, in the order you list them. `where F > 2000` keeps only the rows that pass the test. The last argument, 1, tells QUERY the range has one header row, so the headers come back on top of the result.

## Other ways

- `=VSTACK(CHOOSECOLS(A1:F1,2,4,6),CHOOSECOLS(FILTER(A2:F13,F2:F13>2000),2,4,6))`: The Excel equivalent, header row included.
- `=FILTER({B2:B13,D2:D13,F2:F13},F2:F13>2000)`: FILTER on the three columns joined side by side, when you don't want the header. (No header row.)

## Common mistakes

- Text inside the query needs single quotes, because the whole query sits inside double quotes: `where C = 'East'`.
- Clauses must come in this order: select, where, group by, pivot, order by, limit, offset, label, format. Out of order, QUERY returns #VALUE!.
- Leave out the last argument and QUERY guesses how many header rows there are, and can swallow your first order as a header. Always give 1 or 0.

## Questions

**Can QUERY use column names instead of letters?**

No. With a range, use the column letters. With an array such as `{B2:B13,F2:F13}`, use Col1, Col2 and so on.

**Is QUERY case-sensitive?**

Yes, for text: `where C = 'east'` finds nothing. Compare `lower(C) = 'east'` to ignore case.

Every formula and result on this page was checked by running it in the Spreadsheet Practice formula engine on 2026-10-30.

Source: https://spreadsheetpractice.com/formulas/use-the-query-function
