Table of Contents
Google Sheets is a powerful tool for organizing and analyzing data, and one of its useful features is the ability to use column names in a query. This allows users to easily reference specific columns in their data set without having to remember specific cell references. To use column names in a Google Sheets query, simply include the column names within square brackets after the SELECT statement, separated by commas. This enables users to customize their data queries and retrieve specific information from their data set more efficiently. By using column names in a Google Sheets query, users can save time and streamline their data analysis process.
Use Column Names in Google Sheets Query
You can use the following basic syntax to use a column name in a Google Sheets query:
=QUERY(A1:C11,"SELECT "&SUBSTITUTE(ADDRESS(1,MATCH("Team",A1:C1,0),4),1,""))This particular query will select the column with the name “Team” in the cell range A1:C11.
The following example shows how to use this syntax in practice.
Example: Use Column Name in Google Sheets Query
Suppose we have the following dataset that contains information about various basketball players:

If we would like to select the “Team” column in an ordinary query, we would reference the column as A since it’s the first column in the range we’re interested in:
=QUERY(A1:C11,"SELECT A")This would return just column A:

However, if we attempt to use “Team” as the column name then we’ll receive an error:
=QUERY(A1:C11,"SELECT Team")
Instead, we must use the following formula to select the “Team” column by name:
=QUERY(A1:C11,"SELECT "&SUBSTITUTE(ADDRESS(1,MATCH("Team",A1:C1,0),4),1,""))This will return the “Team” column from the original dataset:

Note that you can use multiple SUBSTITUTE functions if you’d like to select multiple columns by name.
For example, you can use the following syntax to select both the “Team” and “Position” columns by name:
=QUERY(A1:C11,"SELECT "&SUBSTITUTE(ADDRESS(1,MATCH("Team",A1:C1,0),4),1,"")&","&SUBSTITUTE(ADDRESS(1,MATCH("Position",A1:C1,0),4),1,""))The following screenshot shows how to use this formula in practice:

Notice that the query returns both the “Team” and the “Position” columns.
Cite this article
stats writer (2024). How can I use column names in a Google Sheets query?. PSYCHOLOGICAL SCALES. Retrieved from https://scales.arabpsychology.com/stats/how-can-i-use-column-names-in-a-google-sheets-query/
stats writer. "How can I use column names in a Google Sheets query?." PSYCHOLOGICAL SCALES, 26 Jun. 2024, https://scales.arabpsychology.com/stats/how-can-i-use-column-names-in-a-google-sheets-query/.
stats writer. "How can I use column names in a Google Sheets query?." PSYCHOLOGICAL SCALES, 2024. https://scales.arabpsychology.com/stats/how-can-i-use-column-names-in-a-google-sheets-query/.
stats writer (2024) 'How can I use column names in a Google Sheets query?', PSYCHOLOGICAL SCALES. Available at: https://scales.arabpsychology.com/stats/how-can-i-use-column-names-in-a-google-sheets-query/.
[1] stats writer, "How can I use column names in a Google Sheets query?," PSYCHOLOGICAL SCALES, vol. X, no. Y, ص Z-Z, June, 2024.
stats writer. How can I use column names in a Google Sheets query?. PSYCHOLOGICAL SCALES. 2024;vol(issue):pages.
