Google Sheets Query: How to Use Order By


You can use the following syntax to order the results of a Google Sheets Query by a certain column:

=query(A1:C12, "select A, B order by B asc", 1)

In this example, we select columns A and B and order the results by column B ascending. We also specify a 1 to indicate that there is 1 header row at the top of the dataset.

You can also use the following syntax to order by multiple columns:

=query(A1:C12, "select A, B order by B asc, A desc", 1)

In this example, we select columns A and B and order the results by column B ascending, then by column A descending.

The following examples show how to use these formulas in practice.

Example 1: Order By One Column Ascending

We can use the following formula to select the Player and Team columns, then order the results by Team in ascending order:

Example 2: Order By One Column Descending

We can use the following formula to select all of the columns and order the results by Points in descending order:

Google Sheets query order by one column

Example 3: Order by Multiple Columns

We can use the following formula to select all columns and order the results first by Team ascending, then by Points descending:

Google Sheets Query order by multiple columns

Additional Resources

Google Sheets: How to Query From Another Sheet
Google Sheets Query: Select Rows that Contain String
Google Sheets Query: How to Use Group By

Leave a Reply

Your email address will not be published.