Google Sheets Query: How to Use Multiple Criteria in Query


You can use the AND and OR operators to perform a Google Sheets query with multiple criteria.

Example of AND Operator:

=QUERY(A2:C10, "select A, B, C where A contains 'Hello' and C > 10")

Example of OR Operator:

=QUERY(A2:C10, "select A, B, C where A contains 'Hey' or C = 10")

The following examples show how to use each operator in practice.

Example 1: Google Sheets Query Using AND Operator

Suppose we have the following dataset in Google Sheets that contains information about various basketball teams:

We can use the following query to retrieve the teams that are in the East conference and scored more than 90 points:

=QUERY(A2:D11, "select A, B, C, D where B contains 'East' and C > 90")

The following screenshot shows how to use this query in practice:

Notice that the Magic and the Heat are selected because they’re the only two teams that meet both criteria specified in our query.

Example 2: Google Sheets Query Using OR Operator

Once again suppose we have the following dataset in Google Sheets:

We can use the following query to retrieve the teams that are in the East conference or scored more than 90 points:

=QUERY(A2:D11, "select A, B, C, D where B contains 'East' or C > 90")

The following screenshot shows how to use this query in practice:

Every team that is selected met at least one of the criteria specified in our query.

That is, each team selected was either in the ‘East’ conference or they scored more than 90 points.

Additional Resources

The following tutorials explain how to perform other common tasks with Google Sheet queries:

Google Sheets Query: How to Select Multiple Columns
Google Sheets Query: Select Rows that Contain String
Google Sheets Query: How to Use Cell Reference in Formula

Leave a Reply

Your email address will not be published.