Sorting and Grouping in QUERY
Order results and aggregate them with ORDER BY and GROUP BY.
Beyond Filtering
Filtering shows you the right rows, but real reports need order and totals. QUERY handles both with two more SQL-style clauses: ORDER BY and GROUP BY.
With these you can answer questions like which region sells the most or list deals from biggest to smallest, all in one formula.
Sorting With ORDER BY
The ORDER BY clause sorts your results by one or more columns. It goes after WHERE (if present).
By default it sorts ascending (smallest first, A to Z). This formula lists every row sorted by sales from low to high.
=QUERY(A1:D7, "SELECT A, B, D ORDER BY D", 1)All lessons in this course
- Querying Data With QUERY
- Sorting and Grouping in QUERY
- Applying Formulas to Columns With ARRAYFORMULA
- Pulling Data With IMPORTRANGE