How to Query From Another Sheet in Google Sheets?

Querying from another sheet in Google Sheets is a useful way to quickly and easily access data from a separate sheet within the same workbook. To do this, you can use the built-in query function to create a query that references the data from the other sheet. You can then use this query to generate a table of results in the main sheet, which can then be used for further analysis and manipulation.


To query from another tab within the same spreadsheet in Google Sheets, you can use the following syntax:

=query(stats!A1:C9, “select A, B“, 1)

This returns columns A and B from the cell range A1:C9 within the tab named stats. The 1 specifies that there is 1 header row at the top of the dataset being queried.

To query from another spreadsheet entirely, you can use the following syntax:

=query(importrange(“URL“,  “stats!A1:C9“), “select Col1, Col2“, 1)

This returns the first two columns from the cell range A1:C9 within the tab named stats within the Google Sheets spreadsheet with a specific URL.

The following examples show how to use these functions in practice.

Example: Query from Tab in Same Spreadsheet

Suppose we have the following Google Sheets spreadsheet with two tabs: 

  • stats
  • new_sheet

To perform a query on the data in the stats tab and return the results of the query in the new_sheet tab, we can type the following formula in cell A1 of the new_sheet tab:

Example: Query from Another Spreadsheet

Now suppose that we would like to query from another spreadsheet entirely. To do so, we simply need to identify the URL of the Google Sheets spreadsheet that we’d like to query from.

For example, suppose the data we’re interested in is located at the following URL:

Notice the subtle difference between this example and the previous example:

  • When querying from a tab within the same spreadsheet, we use select A, B
  • When querying from an entirely different spreadsheet, we use select Col1, Col2

x