Google Sheets QUERY SELECT: How to Choose Data Columns

How-to basics · Updated November 3, 2026

Google Sheets QUERY SELECT: How to Choose Data Columns

In Google Sheets, the QUERY function’s SELECT clause chooses which columns appear in the results; it can also rearrange them or calculate summaries. With headers in A1:D6 and data in A2:D6, this formula returns the Region and Units columns: =QUERY(A1:D6, "select B, D", 1). The final 1 tells Sheets that the first row contains column headers.

What SELECT Does in QUERY

QUERY is a spreadsheet function that runs a query-language instruction against a range or array and returns matching data as a separate result. Its language resembles SQL, but it is a specific query language supported by Google Sheets—not the full SQL language. SELECT is the part that specifies what to return. It does not change or delete the source cells.

For example, if a table has Date, Region, Item, and Units in columns A through D, SELECT can return just the item and units, or return the region before the item even if the source table has them in the opposite order. You can also select all columns with an asterisk. Selecting fewer columns can make a report easier to scan, but it does not by itself filter out rows; use WHERE for that.

QUERY SELECT Syntax and Column References

The basic structure is QUERY(data, query, [headers]). The data argument is the range or array to analyze, query is a text string containing the instructions, and headers is an optional number describing how many header rows the source has. Inside the query string, a basic selection looks like select A, C.

  • Use commas between selected columns: select A, C, D.
  • Use select * to return every column in the source.
  • For a normal sheet range, columns are commonly identified by letters such as A, B, and C.
  • For an array expression, identify columns by position with names such as Col1 and Col2.

The query instruction is text inside the formula, so its clauses go inside quotation marks. QUERY is not a separate editor or menu command: you enter it in a cell like other Google Sheets functions. When the source data changes, the result normally recalculates, provided the output area is clear.

Build a First SELECT Query

Suppose A1:D6 contains these headers and records: Date, Region, Item, Units; then East, Notebook, 12; West, Pen, 30; East, Pen, 20; North, Notebook, 8; and West, Notebook, 15, with dates in column A for each record. With that layout, selecting columns B and C returns each record’s Region and Item, in that order, while leaving the source table untouched. The header argument is 1 because row 1 contains the headings.

A practical way to build a query is to start with the data range, then add the SELECT clause, and finally specify the header count. If you want to exclude records or sort them, add those clauses after SELECT. For instance, with the same A1:D6 layout, this formula returns Region, Item, and Units only for records with at least 15 units, ordered from the largest number of units to the smallest:

=QUERY(A1:D6, "select B, C, D where D >= 15 order by D desc", 1)

The result contains West / Pen / 30, East / Pen / 20, and West / Notebook / 15. The East notebook row with 12 units and the North notebook row with 8 units do not meet the condition. In the HTML above, the greater-than sign is displayed as an HTML entity; within the actual Google Sheets formula, enter the ordinary characters >= as shown in the code.

Choose, Reorder, and Filter Columns

SELECT controls both which columns appear and their order. If the source has Date in A, Region in B, Item in C, and Units in D, select C, B returns Item first and Region second. The query does not need to follow the original left-to-right order. This is useful when a report is intended for a particular audience—for example, putting the product name first and its location second.

Column selection and row filtering solve different problems. SELECT chooses the fields shown in the output; WHERE decides which records qualify. Common WHERE conditions include comparisons such as D > 10, checking whether a value is present with B is not null, and matching text with conditions such as C = 'Pen'. Text values in the query language use single quotation marks, while the whole query is commonly enclosed in double quotation marks as the formula’s text argument.

With headers in A1:D6 and five records in rows 2–6, selecting columns B and D while excluding blank regions returns the Region and Units for rows whose Region cell is populated. Add order by D desc to sort the qualifying results by Units, largest first. Use limit when you need only the first few rows after filtering and sorting; for example, a limit of 3 returns at most three rows. Sorting before limiting matters when you want the top records rather than simply the first records in source order.

Use SELECT for Grouped Summaries

SELECT can return aggregate calculations as well as ordinary columns. Functions such as sum(), avg(), count(), min(), and max() can summarize values. When the result includes both a regular column and an aggregate, group the results by the regular column with GROUP BY. With Region in B and Units in D in the A1:D6 example, this query totals units by region and sorts the largest total first:

=QUERY(A1:D6, "select B, sum(D) where B is not null group by B order by sum(D) desc label sum(D) 'Total units'", 1)

The expected totals are West 45, East 32, and North 8: West has 30 plus 15, East has 12 plus 20, and North has 8. The label clause gives the calculated column a clearer heading. A common error is selecting a category alongside a sum but forgetting to group by the category; QUERY then cannot form the requested grouped result. Every selected non-aggregated column in a grouped summary should be included in GROUP BY.

Headers, Data Types, and Output Behavior

The optional headers argument describes the input range, not how many rows you want returned. Use 1 when the first row has field names, 0 when the range contains no header row, or another positive number if the source has multiple heading rows. If you omit it, Sheets tries to determine the number of header rows. Supplying the count explicitly can make a query more predictable, especially when the source has unusual headings.

QUERY infers a data type for each column. If a column mixes numbers, dates, and text, the majority type can determine how values are interpreted; values of other types may be treated as null in the query. For example, a number stored as text might not behave like a numeric value in a comparison or sum. Keep each source column consistent, and check whether imported values are genuine dates or numbers rather than text that merely looks like one.

The result expands into nearby cells, so leave enough blank space below and to the right of the formula. If another value blocks the output, Sheets reports an expansion or overwrite error rather than silently replacing that value. Query-generated headings can differ from the original headings, particularly for calculations; LABEL lets you set a clearer output heading. If you only need to change how the result looks, format the result cells separately from the query.

Common QUERY SELECT Problems

  • Wrong column reference: A range such as A1:D6 can use column letters. For an array expression, use positional references such as Col1. A mismatch can cause an unknown-column error.
  • Wrong header count: If the header argument says 0 even though the first row contains headings, that row may be treated as data. If it says 1 when the range starts with records, the first record may be treated as a heading.
  • Text criterion has incorrect quotes: The query is a string inside the formula, and a text value inside that query needs single quotation marks. Check that the outer formula text and inner query-language text are properly closed.
  • Mixed types in a column: A value that looks numeric may be stored as text, or a date may be text. Clean or standardize the source column before relying on numeric comparisons and aggregates.
  • Output cells are occupied: Clear the cells where the returned table needs to expand, or move the formula to an empty area.
  • Unexpected blank rows: Add an appropriate WHERE condition, such as checking that a key column is not null, if blank records should not appear in the result.

When an error appears, reduce the query to its simplest form—first test the range and SELECT, then add WHERE, GROUP BY, or ORDER BY one at a time. This makes it easier to identify whether the issue is a reference, a data type, or a clause in the query.

QUERY Compared with FILTER and Pivot Tables

QUERY is useful when one formula needs to select columns, filter rows, sort results, and summarize values using a compact instruction. FILTER is a more direct choice when the goal is simply to return rows meeting a condition and you do not need QUERY’s grouped summaries or query-language clauses. SORT can order a range, while UNIQUE can return distinct values; neither alone provides the same combination of operations as QUERY.

A pivot table is often easier for readers who want to explore a summary interactively, rearrange fields, or change the report without editing a formula. QUERY is often a better fit for a repeatable formula-driven output that should update from a source range. These approaches serve different needs; a pivot table is not a different spelling of SELECT, and QUERY does not create a full database or modify its source data.

Frequently Asked Questions

How do I select specific columns in Google Sheets QUERY?
Put the column references after SELECT, separated by commas, inside the query string. For example, select A, C returns columns A and C from a sheet range, in that order.

Can QUERY SELECT all columns?
Yes. Use select * to return all columns in the data range. Add WHERE, ORDER BY, or other supported clauses if you also need to filter or organize the rows.

Should I use A or Col1 in a QUERY formula?
For a normal sheet range, use letters such as A and B. For an array expression, use positional names such as Col1 and Col2. If a query reports an unknown column, check which kind of data argument you supplied.

Why does QUERY return a blank or unexpected result?
Check the header count, the referenced columns, and the underlying data types. A text value may not match a numeric condition, mixed-type values may be treated as null, and a condition may exclude every row. Test the simplest SELECT first, then add conditions.

Does Google Sheets QUERY use full SQL?
No. Its syntax is SQL-like, but it follows Google Sheets’ supported query language and has its own rules. Do not assume every SQL command or feature is available; consult Google Sheets function help when a query uses a less common clause.

Is QUERY SELECT the same in Excel?
No. Google Sheets’ QUERY function and its query-language SELECT clause are not built-in Excel functions. Excel has other tools and functions for filtering and summarizing data, but a QUERY formula should not be assumed to work in an Excel workbook.

Related

Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.

More in How-to basics

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.