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), reference columns as Col1, Col2 and so on in the numerical sequence, or 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 as Col1, Col2 and so on in the numerical sequence. If you choose this option, then the data argument from the general Query syntax = QUERY(data, query, [headers]) has to be enclosed in curly brackets {data}.

Syntax

QUERY(data, query, headers)

  • data –  the reference for where our data lives within the Google Sheets
  • query – where we’ll specify what we’re looking for aka the query
    • Note that this parameter is the SQL part, and will be the biggest area of learning
  • headers – optional, the number of rows that are headers in your data