Google Sheets QUERY: Selecting Columns

SELECT

A simple query starts with the keyword SELECT followed by the data to be returned.


Example of use

The goal for this first example will be to select the entire database using the QUERY function.

Enter into the QUERY function:

The following formula does indeed return the entire database:

=QUERY(DB!A1:G15,"SELECT *",1)
google sheets function query all select

In this case =QUERY(DB!A1:G15,"SELECT *",1) returns the same result as if the "headers" argument had not been entered (and therefore automatically calculated by the function) =QUERY(DB!A1:G15,"SELECT *").

To simplify the formulas of the following examples, the "headers" value will not be entered (although it is preferable to do so when you use this function).

Selecting 1 column

To select a single column, enter the letter of the column after SELECT:

=QUERY(DB!A1:G15,"SELECT C")
google sheets function query select 1 column

Selecting multiple columns

To select multiple columns, enter the letter of each column separated by a comma:

=QUERY(DB!A1:G15,"SELECT A, C, E")
google sheets function query select columns