AnyTool
Your files never leave your device. All processing happens locally in your browser.

How do I write a Google Sheets QUERY formula or use functions like IMPORTRANGE and GOOGLEFINANCE?

Use the Google Sheets Helper. Its visual QUERY builder lets you pick a range, choose SELECT columns, add WHERE conditions, GROUP BY, ORDER BY and LIMIT, and it assembles a valid =QUERY(range, "select … where … …", 1) using Google’s Visualization API Query Language. One-form helpers build ARRAYFORMULA, IMPORTRANGE, GOOGLEFINANCE, FILTER, UNIQUE and SPLIT, and a searchable reference lists the Sheets-only functions with syntax and examples. Everything runs in your browser; nothing is uploaded.

  • Visual QUERY() builder: SELECT, WHERE, GROUP BY, ORDER BY, LIMIT → ready formula
  • Full WHERE operator set: =, !=, <, >, contains, starts with, matches, is null
  • Helpers for ARRAYFORMULA, IMPORTRANGE, GOOGLEFINANCE, FILTER, UNIQUE, SPLIT
  • Searchable reference of Sheets-only functions Excel does not have
  • Honest: QUERY uses Google’s query language, which is SQL-like but not SQL
  • 100% client-side — builds formula text, never connects to your sheet

What is

Google Sheets QUERY Function

QUERY is a Google Sheets function that runs a query written in the Google Visualization API Query Language over a range of cells — for example =QUERY(A1:D, "select A, sum(D) where C > 100 group by A order by sum(D) desc", 1). The language is SQL-like but not SQL: clauses must appear in the order select, where, group by, pivot, order by, limit, label, format; text uses single quotes; and dates need a date ‘yyyy-mm-dd’ literal. The Google Sheets Helper builds this for you and also covers other Sheets-only functions such as ARRAYFORMULA, IMPORTRANGE and GOOGLEFINANCE.

Spreadsheets

Related terms

Google SheetsQUERYARRAYFORMULAIMPORTRANGEGOOGLEFINANCEFILTER

Frequently Asked Questions

QUERY runs a query over a range: =QUERY(A1:D, "select A, B where C > 100 order by B desc", 1). The 1 says the first row is a header.

QUERY takes the data range, a query string and the number of header rows. The query string is written in Google’s Visualization API Query Language and its clauses must appear in a fixed order: select (which columns), where (filter), group by, pivot, order by, limit, offset, label and format. So =QUERY(A1:D, "select A, sum(D) where C > 100 group by A order by sum(D) desc", 1) returns one row per value in column A with its total of D, biggest first, for rows where C exceeds 100. Columns are letters (A, B) for a normal range but become Col1, Col2 when the data comes from IMPORTRANGE or an array. The Google Sheets Helper builds the whole formula visually from condition rows and dropdowns.

No. It is SQL-like but it is Google’s own Visualization API Query Language — close, but with different rules.

The QUERY function uses the Google Visualization API Query Language, which borrows SQL keywords like select, where, group by and order by but is not SQL. Key differences: the clauses must appear in a fixed order (select, where, group by, pivot, order by, limit, offset, label, format) or you get a parse error; string values use single quotes; dates are written as a literal like date ‘2026-01-01’; there are no joins; and it adds a PIVOT clause and a LABEL clause that SQL does not have. The Google Sheets Helper writes valid query-language syntax for you, so you do not have to remember the clause order.

QUERY, IMPORTRANGE, IMPORTHTML/DATA/XML, GOOGLEFINANCE, GOOGLETRANSLATE, SPARKLINE and ARRAYFORMULA are Sheets-only.

Several Google Sheets functions have no Microsoft Excel equivalent: QUERY (run a query-language query over a range), the IMPORT family — IMPORTRANGE, IMPORTHTML, IMPORTDATA, IMPORTXML and IMPORTFEED — GOOGLEFINANCE for market data, GOOGLETRANSLATE and DETECTLANGUAGE for language, SPARKLINE for in-cell charts, and ARRAYFORMULA to spill one formula down a whole column. FILTER, SORT, UNIQUE, SPLIT and the LAMBDA helpers also originated in Sheets (some later arrived in Excel 365). The Google Sheets Helper has a searchable reference for all of these, each with syntax and a copyable example.

IMPORTRANGE needs you to grant access the first time — click “Allow access” on the cell. The tool itself uploads nothing.

The first time you link two spreadsheets with IMPORTRANGE, the cell shows #REF! with an “Allow access” button; click it once to grant permission and the data refreshes from then on. The Google Sheets Helper only builds the formula text for you to paste — the QUERY builder, the helper templates and the reference all run as pure functions in your browser, so the ranges, conditions and URLs you type are never uploaded, logged or stored, and it never connects to Google or touches your spreadsheet. Always adjust ranges and column letters to your own sheet and test on a copy.

Detailed Explanation

Methodology

Visual QUERY() Builder for Google’s Query Language

The Google Sheets Helper provides a visual builder for the QUERY function, which runs the Google Visualization API Query Language over a range. The user picks a data range, types the SELECT columns (letters A, B, or * for all, with an aggregate helper that builds sum/avg/count/max/min tokens), stacks WHERE condition rows with the full operator set (=, !=, <, >, <=, >=, contains, starts with, ends with, matches, like, is null, is not null) joined by and/or, sets GROUP BY, ORDER BY with asc/desc and LIMIT, and the tool assembles a valid =QUERY(range, "select … where … group by … order by … limit …", headers) live, in the required clause order. It echoes the raw query-language string and a plain-English explanation of what the query returns. Values are quoted intelligently — numbers and booleans stay bare, text and text-match operators get single quotes, and date ‘yyyy-mm-dd’ literals pass through untouched.

  • Builds =QUERY() in the required clause order: select, where, group by, order by, limit
  • WHERE supports contains, starts with, ends with, matches, like, is null and and/or joins
  • Aggregate helper builds sum(), avg(), count(), max(), min() tokens for SELECT
  • Smart quoting: numbers bare, text single-quoted, date ‘yyyy-mm-dd’ literals preserved
  • Shows the raw query-language string plus a plain-English explanation
Technical Details

Helpers and Reference for Sheets-Only Functions

Beyond QUERY, the tool offers one-form helpers that build the formulas for the Google-Sheets-exclusive power functions: ARRAYFORMULA (wrap a per-row formula so it fills a column), IMPORTRANGE (pull a range from another spreadsheet by URL, with a note that access must be granted the first time), GOOGLEFINANCE (fetch a live or historical market quote by ticker and attribute), and FILTER, UNIQUE and SPLIT for shaping data. A set of ready-to-adapt recipes covers a group-and-total pivot, pivoting months into columns, a date-window filter using date literals, querying an IMPORTRANGE with Col1/Col2 references, a live top-N list, and a stock sparkline. A searchable, categorised reference lists the Sheets-only functions — QUERY, the IMPORT family (IMPORTRANGE/HTML/DATA/XML/FEED), GOOGLEFINANCE, GOOGLETRANSLATE, DETECTLANGUAGE, SPARKLINE, IMAGE, FILTER/SORT/SORTN/UNIQUE/FLATTEN/SEQUENCE, SPLIT/JOIN/TEXTJOIN, the REGEX* trio and the LAMBDA helpers — each with syntax, a description and a copyable example.

  • One-form builders for ARRAYFORMULA, IMPORTRANGE, GOOGLEFINANCE, FILTER, UNIQUE, SPLIT
  • Ready recipes: group-and-total pivot, PIVOT clause, date windows, top-N, sparkline
  • Searchable reference of the IMPORT family, GOOGLEFINANCE, SPARKLINE, REGEX* and LAMBDA
  • IMPORTRANGE helper flags that access must be granted on first link
  • Every reference entry and recipe has a one-click copy button
Limitations

Sheets-Only and SQL-Like, Not SQL — and Fully Private

The tool is explicit that these are Google Sheets functions and that several — QUERY, IMPORTRANGE, GOOGLEFINANCE, SPARKLINE, ARRAYFORMULA — do not exist in Microsoft Excel, and that the QUERY language is SQL-like but not SQL: its clauses must follow a fixed order, text uses single quotes, dates need a date literal, there are no joins, and columns become Col1/Col2 when the data comes from IMPORTRANGE or an array. It reminds users that IMPORTRANGE needs access granted on the first link, that ranges and column letters must be adjusted to their own sheet, and that they should test on a copy. The QUERY builder, the helper templates and the reference all run as pure string-building functions in the browser, so the ranges, conditions, tickers and URLs typed are never uploaded, logged or stored; the tool produces formula text to paste and never connects to Google or touches the spreadsheet, and it works offline once cached.

  • Honest: Sheets-only functions; several have no Excel equivalent
  • QUERY language is SQL-like but not SQL — fixed clause order, single quotes, date literals, no joins
  • IMPORTRANGE requires granting access on the first link
  • Builds formula text only — never connects to Google or the user’s sheet
  • Ranges, conditions, tickers and URLs are never uploaded; works offline once cached
Google Sheets QUERY/helper building: in-browser (AnyTool) vs typical online QUERY generators
CapabilityAnyToolTypical online QUERY generators
ProcessingRuns entirely in your browserSends your request to a server/LLM
QUERY builderVisual clauses in the correct order, live previewFree-text prompt, may emit wrong clause order
WHERE operatorsFull set incl. contains, matches, is nullOften only =, <, >
Sheets-only helpersARRAYFORMULA, IMPORTRANGE, GOOGLEFINANCE, FILTER, UNIQUE, SPLITUsually QUERY only
ReferenceSearchable Sheets-only function list with examplesRarely included
HonestyStates QUERY is not SQL; flags IMPORTRANGE accessOften implies SQL parity
PrivacyNothing uploaded, works offlineRequest transmitted and may be logged
Cost / signupFree, no signupOften gated or rate-limited

AnyTool builds the formula text locally in the browser and uploads nothing you type.