1: Google Sheets Query: SELECT
The SELECT clause allows defining the columns you want to fetch and the order in which you want to organize them in your new worksheet. If the order is not specified, the data will be returned “as is” in a source spreadsheet.
One can use column IDs (the letters located at the top of every column in a spreadsheet), for example, SELECT A, B, or reference columns as Col1, Col2 and so on in the numerical sequence. You can also reference the results of arithmetic operators, scalar or aggregation functions as elements to order in this clause.
Note: if you are planning to embed Query into more complex formulas, we recommend referencing columns Col1, Col2, and so on in the numerical sequence. If you choose this option, then the data argument from the general Query syntax has to be enclosed in curly brackets.
= QUERY({data}, query, [headers])
Google Sheets Query SELECT all example
=query('data from Airtable'!A:L,"select *")
Note The headers parameter allows you to specify the number of header rows to return. If you omit the header element, the returned data will include the heading row. To remove the headers, type “0” in your Query formula like this:
=query('data from Airtable'!A:I,"select *", 0)
Google Sheets Query SELECT one or multiple columns example
If a user wants to fetch only a certain or multiple columns, one needs to define them by a column ID like as follows:
=query('data from Airtable'!A:L,"select C, E, I")
'data from Airtable'!A:L – the data range to query on
"select C, E, I" – pull all data from the columns C, E, I
Google Sheets Query SELECT multiple sheets example
If you need to query different sheets in Google Sheets, meaning that you want to select data from several different tabs of a spreadsheet, then feel free to use the below example:
=query({'data from Airtable'!A1:L; Sheet1!A1:L; Sheet2!A1:L}, "select * where Col1 is not null")
{'data from Airtable'!A1:L; Sheet1!A1:L; Sheet2!A1:L} – an array formula enclosed into curly brackets which includes the list of sheets I want to pull data from, separated by semicolons.
"select * where Col1 is not null" – pull all data where the contents of the rows in column 1 (column A, Order ID) are not empty. Continue reading this article to learn more about the Where clause, as well as “is null” and “is not null” operators.