---
title: "QUERY in Google Sheets: syntax and examples | PracticeExcel"
description: "How to use QUERY in Google Sheets: select, where, group by and order by, with examples and practice that is checked as you type."
canonical_url: "https://practiceexcelonline.com/sheets/functions/query"
locale: en
meta:
  "og:description": "How to use QUERY in Google Sheets: select, where, group by and order by, with examples and practice that is checked as you type."
  "og:image": "https://practiceexcelonline.com/_og/d/c_Page%2Ctitle_~UVVFUlkgaW4gR29vZ2xlIFNoZWV0czogc3ludGF4IGFuZCBleGFtcGxlcw%2Cdescription_~SG93IHRvIHVzZSBRVUVSWSBpbiBHb29nbGUgU2hlZXRzOiBzZWxlY3QsIHdoZXJlLCBncm91cCBieSBhbmQgb3JkZXIgYnksIHdpdGggZXhhbXBsZXMgYW5kIHByYWN0aWNlIHRoYXQgaXMgY2hlY2tlZCBhcyB5b3UgdHlwZS4%2Ceyebrow_Google%2BSheets%2Bpractice%2Bexercises%2Csite_practiceexcel%2Ccode_~UVVFUlkoZGF0YSwgcXVlcnksIFtoZWFkZXJzXSk%2Cp_Ii9zaGVldHMvZnVuY3Rpb25zL3F1ZXJ5Ig%2Cs_iVA3TPo65taPwNtR.png"
  "og:image:height": "600"
  "og:image:type": image/png
  "og:image:width": "1200"
  "og:title": "QUERY in Google Sheets: syntax and examples | PracticeExcel"
  "twitter:image": "https://practiceexcelonline.com/_og/d/c_Page%2Ctitle_~UVVFUlkgaW4gR29vZ2xlIFNoZWV0czogc3ludGF4IGFuZCBleGFtcGxlcw%2Cdescription_~SG93IHRvIHVzZSBRVUVSWSBpbiBHb29nbGUgU2hlZXRzOiBzZWxlY3QsIHdoZXJlLCBncm91cCBieSBhbmQgb3JkZXIgYnksIHdpdGggZXhhbXBsZXMgYW5kIHByYWN0aWNlIHRoYXQgaXMgY2hlY2tlZCBhcyB5b3UgdHlwZS4%2Ceyebrow_Google%2BSheets%2Bpractice%2Bexercises%2Csite_practiceexcel%2Ccode_~UVVFUlkoZGF0YSwgcXVlcnksIFtoZWFkZXJzXSk%2Cp_Ii9zaGVldHMvZnVuY3Rpb25zL3F1ZXJ5Ig%2Cs_iVA3TPo65taPwNtR.png"
---

> Index of every page on this site: [llms.txt](https://practiceexcelonline.com/llms.txt)

# **QUERY in Google Sheets**

Runs a query on a range with select, where, group by and order by, and returns the result as a table.

=

QUERY(

## **Syntax**

```
QUERY(data, query, [headers])
```

<dl><dt>**data **</dt>
<dd>The range to query. Its columns are called A, B, C… after the sheet letters.</dd>
<dt>**query **</dt>
<dd>The query as text in quotes, such as "select A, B where C &gt; 100".</dd>
<dt>**headers **(optional)</dt>
<dd>The number of header rows in the data. Left out, Google Sheets guesses.</dd></dl>

## **Examples**

E1`=QUERY(<sup>1</sup>A1:C6,<sup>2</sup>"select A, sum(C) group by A")`

|  | A | B | C | D | E | F |
| --- | --- | --- | --- | --- | --- | --- |
| 1 | Region | Rep | Amount |  | **Region** | **sum Amount** |
| 2 | North | Ann | 120 |  | **North** | **320** |
| 3 | South | Bo | 80 |  | **South** | **230** |
| 4 | North | Cy | 200 |  | **West** | **50** |
| 5 | West | Di | 50 |  |  | |
| 6 | South | Ed | 150 |  |  | |

**In plain words:** From <sup>1</sup>the table in A1:C6, <sup>2</sup>list each region in column A with the total of column C.

E1=QUERY(A1:C6,"select B where C > 100 order by C desc")

|  | A | B | C | D | E |
| --- | --- | --- | --- | --- | --- |
| 1 | Region | Rep | Amount |  | **Rep** |
| 2 | North | Ann | 120 |  | **Cy** |
| 3 | South | Bo | 80 |  | **Ed** |
| 4 | North | Cy | 200 |  | **Ann** |
| 5 | West | Di | 50 |  | |
| 6 | South | Ed | 150 |  | |

## **Practice QUERY**

- [**1****Pick columns with select**→](https://practiceexcelonline.com/sheets/practice/query/query-select-columns)
- [**2****Keep rows with where**→](https://practiceexcelonline.com/sheets/practice/query/query-where-number)
- [**3****Match text in where**→](https://practiceexcelonline.com/sheets/practice/query/query-where-text)
- [**4****Totals per group with group by**→](https://practiceexcelonline.com/sheets/practice/query/query-group-by-sum)
- [**5****Top results with order by and limit**→](https://practiceexcelonline.com/sheets/practice/query/query-order-by-limit)

## **Related functions**

- [**FILTER**](https://practiceexcelonline.com/functions/filter)
- [**SUMIF**](https://practiceexcelonline.com/sheets/functions/sumif)
- [**COUNTIF**](https://practiceexcelonline.com/sheets/functions/countif)

```json
{"@context":"https://schema.org","@graph":[{"@id":"https://practiceexcelonline.com/#identity","@type":"Organization","name":"PracticeExcel","url":"https://practiceexcelonline.com/","logo":{"@id":"https://practiceexcelonline.com/#logo"}},{"@id":"https://practiceexcelonline.com/#website","@type":"WebSite","inLanguage":"en-US","name":"PracticeExcel","url":"https://practiceexcelonline.com/","alternateName":["Practice Excel Online","PracticeExcelOnline.com"],"publisher":{"@id":"https://practiceexcelonline.com/#identity"},"workTranslation":{"@id":"https://excelopgaver.dk/#website"}},{"@id":"https://practiceexcelonline.com/sheets/functions/query#webpage","@type":"WebPage","description":"How to use QUERY in Google Sheets: select, where, group by and order by, with examples and practice that is checked as you type.","name":"QUERY in Google Sheets: syntax and examples","url":"https://practiceexcelonline.com/sheets/functions/query","breadcrumb":{"@id":"https://practiceexcelonline.com/sheets/functions/query#breadcrumb"},"isPartOf":{"@id":"https://practiceexcelonline.com/#website"},"potentialAction":[{"@type":"ReadAction","target":["https://practiceexcelonline.com/sheets/functions/query"]}],"primaryImageOfPage":{"@id":"https://practiceexcelonline.com/#logo"}},{"@id":"https://practiceexcelonline.com/sheets/functions/query#breadcrumb","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","name":"Home","item":"https://practiceexcelonline.com","position":1},{"@type":"ListItem","name":"Google Sheets practice exercises","item":"https://practiceexcelonline.com/sheets","position":2},{"@type":"ListItem","name":"QUERY in Google Sheets: syntax and examples","position":3}]},{"@id":"https://practiceexcelonline.com/sheets/functions/query#article","description":"How to use QUERY in Google Sheets: select, where, group by and order by, with examples and practice that is checked as you type.","headline":"QUERY in Google Sheets: syntax and examples","inLanguage":"en-US","thumbnailUrl":"https://practiceexcelonline.com/_og/d/c_Page%2Ctitle_~UVVFUlkgaW4gR29vZ2xlIFNoZWV0czogc3ludGF4IGFuZCBleGFtcGxlcw%2Cdescription_~SG93IHRvIHVzZSBRVUVSWSBpbiBHb29nbGUgU2hlZXRzOiBzZWxlY3QsIHdoZXJlLCBncm91cCBieSBhbmQgb3JkZXIgYnksIHdpdGggZXhhbXBsZXMgYW5kIHByYWN0aWNlIHRoYXQgaXMgY2hlY2tlZCBhcyB5b3UgdHlwZS4%2Ceyebrow_Google%2BSheets%2Bpractice%2Bexercises%2Csite_practiceexcel%2Ccode_~UVVFUlkoZGF0YSwgcXVlcnksIFtoZWFkZXJzXSk%2Cp_Ii9zaGVldHMvZnVuY3Rpb25zL3F1ZXJ5Ig%2Cs_iVA3TPo65taPwNtR.png","@type":["Article","TechArticle"],"author":{"@id":"https://practiceexcelonline.com/#identity"},"image":{"@id":"https://practiceexcelonline.com/#/schema/image/1"},"isPartOf":{"@id":"https://practiceexcelonline.com/sheets/functions/query#webpage"},"mainEntityOfPage":{"@id":"https://practiceexcelonline.com/sheets/functions/query#webpage"},"publisher":{"@id":"https://practiceexcelonline.com/#identity"}},{"@id":"https://practiceexcelonline.com/#logo","@type":"ImageObject","caption":"PracticeExcel","contentUrl":"https://practiceexcelonline.com/brand/practiceexcel/icon-512.png","inLanguage":"en-US","url":"https://practiceexcelonline.com/brand/practiceexcel/icon-512.png"},{"@id":"https://practiceexcelonline.com/#/schema/image/1","@type":"ImageObject","contentUrl":"https://practiceexcelonline.com/_og/d/c_Page%2Ctitle_~UVVFUlkgaW4gR29vZ2xlIFNoZWV0czogc3ludGF4IGFuZCBleGFtcGxlcw%2Cdescription_~SG93IHRvIHVzZSBRVUVSWSBpbiBHb29nbGUgU2hlZXRzOiBzZWxlY3QsIHdoZXJlLCBncm91cCBieSBhbmQgb3JkZXIgYnksIHdpdGggZXhhbXBsZXMgYW5kIHByYWN0aWNlIHRoYXQgaXMgY2hlY2tlZCBhcyB5b3UgdHlwZS4%2Ceyebrow_Google%2BSheets%2Bpractice%2Bexercises%2Csite_practiceexcel%2Ccode_~UVVFUlkoZGF0YSwgcXVlcnksIFtoZWFkZXJzXSk%2Cp_Ii9zaGVldHMvZnVuY3Rpb25zL3F1ZXJ5Ig%2Cs_iVA3TPo65taPwNtR.png","inLanguage":"en-US","url":"https://practiceexcelonline.com/_og/d/c_Page%2Ctitle_~UVVFUlkgaW4gR29vZ2xlIFNoZWV0czogc3ludGF4IGFuZCBleGFtcGxlcw%2Cdescription_~SG93IHRvIHVzZSBRVUVSWSBpbiBHb29nbGUgU2hlZXRzOiBzZWxlY3QsIHdoZXJlLCBncm91cCBieSBhbmQgb3JkZXIgYnksIHdpdGggZXhhbXBsZXMgYW5kIHByYWN0aWNlIHRoYXQgaXMgY2hlY2tlZCBhcyB5b3UgdHlwZS4%2Ceyebrow_Google%2BSheets%2Bpractice%2Bexercises%2Csite_practiceexcel%2Ccode_~UVVFUlkoZGF0YSwgcXVlcnksIFtoZWFkZXJzXSk%2Cp_Ii9zaGVldHMvZnVuY3Rpb25zL3F1ZXJ5Ig%2Cs_iVA3TPo65taPwNtR.png"}]}
```

## Sitemap

See the full [sitemap](https://practiceexcelonline.com/sitemap.md) for all pages.
