QUERY (Google Sheets SQL)
QUERY brings SQL-style data wrangling to Google Sheets — filter, group, pivot, join. Every QUERY recipe and pattern collected here.
12 pages · 11 how-to, 1 error fix
How-to guides
How to use QUERY to filter data
Use Google Sheets QUERY with a WHERE clause to filter rows dynamically — Excel users can use FILTER as the equivalent.
Excel ≠ SheetsHow to use QUERY to sum by group
Use Google Sheets QUERY with GROUP BY and SUM to aggregate data by category — use SUMIF for the Excel equivalent.
Excel ≠ SheetsHow to use QUERY to group by multiple columns
Use QUERY GROUP BY with multiple columns in Google Sheets to create multi-level summaries. Excel alternative uses SUMIFS with multiple criteria ranges.
Excel ≠ SheetsHow to use QUERY with WHERE, AND, OR
Filter QUERY results in Google Sheets using WHERE with AND and OR conditions. Excel users can replicate this with FILTER using * for AND and + for OR.
Excel ≠ SheetsHow to create a running total with QUERY
Build a running total in Google Sheets by combining QUERY for ordering with ARRAYFORMULA and SUMIF. Excel alternative uses a simple SUMIF with a locked anchor row.
Excel ≠ SheetsHow to combine QUERY with IMPORTRANGE
Combine QUERY and IMPORTRANGE in Google Sheets to filter and aggregate data from another spreadsheet file. There is no Excel equivalent — use Power Query to connect workbooks instead.
Excel ≠ SheetsHow to use cell references inside QUERY criteria
Inject cell references into a QUERY formula's WHERE clause in Google Sheets using string concatenation. Excel uses FILTER with direct cell references instead.
Excel ≠ SheetsHow to skip header rows in QUERY
Control how many header rows QUERY reads in Google Sheets using the headers argument — set it to 0, 1, or -1 to fix missing or doubled headers. Excel FILTER needs no equivalent setting.
Excel ≠ SheetsHow to use QUERY with date comparisons
Filter rows by date in Google Sheets QUERY using the date literal syntax. Excel alternative uses FILTER with comparison operators on date serial numbers.
Excel ≠ SheetsHow to use QUERY with LIKE wildcards
Use QUERY's LIKE operator with % wildcards to filter rows by partial text matches in Google Sheets. Excel alternative uses FILTER with SEARCH or ISNUMBER/FIND.
Excel ≠ SheetsHow to use QUERY for conditional aggregation
Use QUERY with WHERE and GROUP BY to conditionally aggregate data in Google Sheets — equivalent to SUMIFS or COUNTIFS but with richer filtering and label control.
Excel ≠ Sheets