Top ten customers
=QUERY(Sales!A1:D, "select A, sum(D) group by A order by sum(D) desc limit 10 label sum(D) 'Revenue'", 1)
The QUERY function runs a SQL-like statement against a range in your sheet. You SELECT columns, filter with WHERE, sort with ORDER BY, and aggregate with GROUP BY without building many helper columns. It is the closest native option to a small in-sheet database query.
Use QUERY when you filter and summarize rectangular data often: top products by revenue, active rows from a staging tab, or pivot-like rollups that would need messy FILTER stacks.
Skip QUERY for one-line lookups (use XLOOKUP or INDEX/MATCH), heavy joins across many keys, or when teammates cannot read SQL-ish strings in formulas.
Point QUERY at a range including headers, for example QUERY(Data!A1:F, "select ...", 1).
Write select Col1, sum(Col3) with column letters as Col1, Col2 matching the range width.
Add where Col4 = 'Active' and order by Col3 desc for filtered sorted output.
Use label sum(Col3) 'Total' to rename output headers for dashboards.
Wrap in ARRAYFORMULA only when combining QUERY output with other arrays; QUERY already spills.
Test the query in the query generator or a scratch cell before embedding in a published dashboard.
=QUERY(Sales!A1:D, "select A, sum(D) group by A order by sum(D) desc limit 10 label sum(D) 'Revenue'", 1)
=QUERY(Tasks!A1:E, "select A, B, C where E <> 'Done' order by D asc", 1) lists incomplete work.
Helper column with TEXT date as month, then QUERY groups spend by month for a chart source tab.
Build this without starting from a blank cell
Use a Better Sheets tool for SQL-style queries (QUERY), then watch a walkthrough when you want the full pattern.
Watch how SQL-style queries (QUERY) works
Filtering hides rows that do not match criteria without deleting data. The filter toolbar on a header row is the fastest UI path. FILTER and QUERY formulas build dynamic views that update when source data changes, which suits dashboards and reporting tabs.
Read guide →Sorting reorders rows by one or more columns. The Data > Sort range menu sorts selection in place. The SORT function returns a sorted copy that updates when inputs change. Always decide whether related columns must move together as a single row unit.
Read guide →Every formula starts with = followed by a function name and arguments in parentheses. Ranges use A1 notation, text sits in quotes, and operators like + and & combine values. Sheets recalculates when inputs change, so syntax errors show as #NAME? or #ERROR! in the cell.
Read guide →A dashboard is a single view that answers "how are we doing?" without hunting across tabs. In Google Sheets, it is usually a summary tab with big numbers, charts, and conditional formatting fed by QUERY, pivot tables, or IMPORTRANGE from raw data you keep elsewhere.
Read guide →Done reading about SQL-style queries (QUERY)?
Membership unlocks 636+ tutorials, unlimited generators, and every template. Practical lessons. Zero fluff.
Need this once
Jump to a free tool or a single tutorial for this topic.
Learning Sheets for real
Unlock the full library, generators, and templates with membership.