To select multiple columns in a Google Sheets QUERY, list them by letter (e.g., SELECT A, C, E) or by column name in the SELECT clause, separating each with a comma. For example, =QUERY(A1:E100, "SELECT A, C, E", 1) returns columns A, C, and E from the range.
What the QUERY Function Does
QUERY is Google Sheets’ built-in tool for running SQL-like queries on your data. It reads a rectangular range and returns a new table based on the query string you provide. The syntax is:
=QUERY(data, query, [headers])
- data – the range to query, like
A1:E100. - query – a text string (in quotes) starting with
SELECT. - headers – optional; enter
1if the first row contains column labels, or0if not.
The query language is case-insensitive for keywords, but column letters must match your range exactly. If your data has header names with spaces or special characters, you must wrap them in backticks, like SELECT `First Name`, `Last Name`.
How to Select Multiple Columns
The simplest way is to list column letters after SELECT. For instance, with data in A1:F50, to get columns B, D, and F:
=QUERY(A1:F50, "SELECT B, D, F", 1)
This returns only those three columns, preserving the original row order. You can also use column names if you set the header row:
=QUERY(A1:F50, "SELECT `Product Name`, Price", 1)
Both methods work, but letters are faster to type and less error-prone when names change. To select all columns, use SELECT *. To reorder columns, just change the order in the list, e.g., SELECT C, A.
Selecting Columns with Conditions
You can combine column selection with a WHERE clause to filter rows. For example, to select columns A and B only where column C is greater than 100:
=QUERY(A1:C100, "SELECT A, B WHERE C > 100", 1)
You can also use ORDER BY, LIMIT, and LABEL in the same query. For instance:
=QUERY(A1:C100, "SELECT A, B ORDER BY B DESC LIMIT 10", 1)
This returns the top 10 rows sorted by column B. The SELECT clause always comes first, and the other clauses follow in a specific order: WHERE, GROUP BY, PIVOT, ORDER BY, LIMIT, OFFSET, LABEL, FORMAT.
Common Mistakes and How to Fix Them
Several errors trip up new users when selecting multiple columns:
- Missing commas –
SELECT A Bfails; you needSELECT A, B. - Header count mismatch – If you set
headersto1but your data has no header row, the first row gets treated as labels and disappears. Use0if there are no headers. - Backtick issues – Column names with spaces require backticks, not quotes.
SELECT 'First Name'will error. - Out-of-range letters – If your range is A1:C100, you cannot select column D. Extend the range first.
- Quoting the query – The query string must be in double quotes, and any internal text values in
WHEREneed single quotes, likeWHERE B = 'Yes'.
If you see a #VALUE! error, check the query syntax. If you see #REF!, the range is invalid. If you see #N/A, the query returned no data.
Selecting Non-Adjacent Columns with QUERY vs. Other Functions
QUERY is not the only way to pull multiple columns. You might also use:
- FILTER –
=FILTER(A1:E100, C1:C100 > 100)returns whole rows, but you can wrap it withCHOOSECOLSorINDEXto pick columns. - ARRAYFORMULA – Combine with
{A:A, C:C}to create an array of columns. - INDEX –
=INDEX(A1:E100, 0, {1,3,5})returns columns 1, 3, and 5 (but this works only in newer versions of Google Sheets).
QUERY is more powerful when you need filtering, sorting, or aggregation in one step. For simple column extraction, FILTER or INDEX may be easier to read.
Using QUERY with Aggregation and Grouping
When you select multiple columns with GROUP BY, every column in the SELECT clause must either be grouped or wrapped in an aggregate function like SUM(), AVG(), COUNT(), or MAX(). For example, to sum sales by region (columns A and B):
=QUERY(A1:B100, "SELECT A, SUM(B) GROUP BY A", 1)
This returns one row per unique value in column A with the total of column B. If you try to select a column that isn’t grouped and isn’t aggregated, you’ll get a parse error.
How to Select Columns in Excel (and Why It Differs)
Excel does not have a QUERY function. The closest equivalent is FILTER, but it returns whole rows. To select specific columns, you can use CHOOSECOLS (available in Excel 365) like this:
=CHOOSECOLS(A1:E100, 1, 3, 5)
This returns columns 1, 3, and 5 from the range. In older Excel versions, you might use INDEX with an array constant, but that requires CSE (Ctrl+Shift+Enter) in pre-dynamic-array versions. Google Sheets’ QUERY is more flexible for complex data manipulation, but Excel’s modern functions are faster for simple column picks.
Frequently Asked Questions
Can I select columns by header name instead of letter?
Yes, if you include a header row and set the headers argument to 1. Use backticks around names with spaces, like SELECT `Sales Amount`. This is useful when your column order changes, but it makes the query longer.
How do I select all columns except one?
QUERY doesn’t support a “except” syntax. You must list the columns you want explicitly. Alternatively, use FILTER with CHOOSECOLS to exclude a column by number, but that’s more complex.
Why does my QUERY return a header row even when I don’t want it?
If you set headers to 1, the first row of your data is treated as headers and appears in the result. If you don’t want that, set headers to 0 and use column letters in the query, or omit the header argument entirely (defaults to -1, which guesses).
Can I use QUERY to select columns from another sheet?
Yes, reference the sheet with the sheet name and range, like =QUERY(Sheet2!A1:C100, "SELECT A, C", 1). If the sheet name has spaces, wrap it in single quotes: 'My Sheet'!A1:C100.
What does the #VALUE! error mean in QUERY?
It usually means the query string is malformed—missing commas, wrong quotes, or invalid column names. Check the syntax carefully, and make sure column letters match the range.
Is QUERY case-sensitive?
No, keywords like SELECT and WHERE are not case-sensitive, but text values in WHERE are case-sensitive by default. To ignore case, use LOWER() or UPPER() on both sides.
Related
- Shortcut for Cutting? Fastest Ways to Slice
- How to Outsource Data Entry: Best Options Compared
- Google Sheets Query Not Equal: Syntax & Examples
Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.
More in How-to basics
- ArcGIS for Excel Heat Maps: Setup, Uses, and LimitsYes. ArcGIS for Excel can display mapped point data as a heat map: add your location data to…
- Unknown Range Name in Google Sheets: Causes and Fixes“Unknown range name” in Google Sheets means a formula contains a word or reference that Sheets is treating…
- Can You Automatically Alphabetize Tabs in Google Sheets?Yes, you can alphabetize sheet tabs in Google Sheets, but there is no built-in command that sorts them…
- Excel Data Analysis Toolkit: Setup, Tools, and Practical UsesExcel’s data analysis toolkit is a collection of features for summarizing, exploring, and modeling data; the name often…
- Remove All Formatting in Word Without Losing TextTo remove formatting from a Word document, save a copy, press Ctrl+A on Windows (Command+A on Mac), then…
- Excel Remove Duplicates from a Table Without Losing DataTo remove duplicate rows from an Excel table, click a cell in the table, choose Data > Remove…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.