6.2 C
London
Thursday, December 19, 2024
HomeSoftware TutorialsGoogle SheetsGoogle Sheets Query: How to Use Multiple Criteria in Query

Google Sheets Query: How to Use Multiple Criteria in Query

Related stories

Learn About Opening an Automobile Repair Shop in India

Starting a car repair shop is quite a good...

Unlocking the Power: Embracing the Benefits of Tax-Free Investing

  Unlocking the Power: Embracing the Benefits of Tax-Free Investing For...

Income Splitting in Canada for 2023

  Income Splitting in Canada for 2023 The federal government’s expanded...

Can I Deduct Home Office Expenses on my Tax Return 2023?

Can I Deduct Home Office Expenses on my Tax...

Canadian Tax – Personal Tax Deadline 2022

  Canadian Tax – Personal Tax Deadline 2022 Resources and Tools...

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

Subscribe

- Never miss a story with notifications

- Gain full access to our premium content

- Browse free from up to 5 devices at once

Latest stories