12.4 C
London
Thursday, June 5, 2025
HomeSoftware TutorialsGoogle SheetsGoogle Sheets Query: How to Use LIMIT to Limit Rows

Google Sheets Query: How to Use LIMIT to Limit Rows

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 LIMIT clause to limit the number of rows returned by a Google Sheets query.

The LIMIT clause is particularly useful when you want to get a glimpse at a few rows that meet some criteria without displaying every row in the entire dataset that meets some criteria.

This clause uses the following basic syntax:

=QUERY(A1:C11, "SELECT * LIMIT 5")

This particular query will return the header row from the range A1:C11 along with the first 5 rows.

The following example shows how to use the LIMIT clause in practice

Example: Using LIMIT in Google Sheets Query

Suppose we have the following dataset that contains information about various basketball players:

We can use the following query to return the header row along with the first five rows in the dataset:

=QUERY(A1:C11, "SELECT * LIMIT 5")

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

Notice that the header row along with the first five rows are returned.

It’s worth noting that if the query would naturally return less than 5 rows, then the LIMIT clause won’t force the output to display five rows.

For example, suppose we use the following query to display all players who have more than 25 points:

=QUERY(A1:C11, "SELECT * WHERE C > 25 LIMIT 5")

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

Notice that only two rows are returned because there are only two players in the original dataset that have more than 25 points.

Notice that the LIMIT 5 clause didn’t force the output to have 5 rows.

Rather, the LIMIT clause simply sets a maximum value on the number of rows that will be returned.

Additional Resources

The following tutorials explain how to perform other common operations in Google Sheets:

Google Sheets Query: How to Return Only Unique Rows
Google Sheets Query: How to Remove Header from Results
Google Sheets Query: How to Ignore Blank Cells in Query

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