Syntax or pattern
Use QUERY to build a pivot-style summary table.
=QUERY(data, "select A, sum(C) group by A pivot B", 1)5 practical examples
Build a clean table with QUERY PIVOT
Return only the columns and rows needed for a report.
=QUERY(A1:E, "select A, B, E where E is not null", 1)Adjust the ranges, criteria and sheet names to match your workbook.
Summarize by category
Create a category summary without a pivot table.
=QUERY(A1:E, "select B, sum(E) group by B", 1)Adjust the ranges, criteria and sheet names to match your workbook.
Show top records
Return the top rows for a quick dashboard.
=QUERY(A1:E, "select A, E order by E desc limit 10", 1)Adjust the ranges, criteria and sheet names to match your workbook.
Filter by text
Show records that match a selected status.
=QUERY(A1:E, "select A, B where C = 'Open'", 1)Adjust the ranges, criteria and sheet names to match your workbook.
Group by month
Summarize monthly data after preparing date labels.
=QUERY({A2:A, E2:E}, "select Col1, sum(Col2) group by Col1", 0)Adjust the ranges, criteria and sheet names to match your workbook.
Common mistakes to avoid
- Using column letters instead of Col1 notation with imported array data.
- Forgetting quotes inside QUERY strings.
- Grouping without aggregating non-grouped columns.
FAQ
What is this Google Sheets page for?
This page gives copy-ready examples for query pivot examples so you can understand the pattern and adapt it to real spreadsheet work.
Can I copy these formulas directly?
Yes. Use the copy buttons, then adjust sheet names, ranges, criteria and column references for your own file.
Why does my formula return an error?
The most common causes are mismatched ranges, missing quotes around text criteria, blank source data, or references that do not match your sheet layout.