---
title: "QUERY practice in Google Sheets | ExcelSavvy"
description: "Practice the Google Sheets QUERY function: select, where, group by, order by and limit in a live grid."
canonical_url: "https://excelsavvy.com/sheets/practice/query"
meta:
  "og:description": "Practice the Google Sheets QUERY function: select, where, group by, order by and limit in a live grid."
  "og:image": "https://excelsavvy.com/_og/d/c_Page%2Ctitle_QUERY%2Bpractice%2Bin%2BGoogle%2BSheets%2Cdescription_~UHJhY3RpY2UgdGhlIEdvb2dsZSBTaGVldHMgUVVFUlkgZnVuY3Rpb246IHNlbGVjdCwgd2hlcmUsIGdyb3VwIGJ5LCBvcmRlciBieSBhbmQgbGltaXQgaW4gYSBsaXZlIGdyaWQu%2Ceyebrow_Google%2BSheets%2Bpractice%2Bexercises%2Csite_practiceexcel%2Cprops_eyJncmlkIjp7ImNvbHMiOlsiQSIsIkIiLCJDIiwiRSJdLCJyb3dzIjpbeyJuIjoxLCJjZWxscyI6WyJSZWdpb24iLCJSZXAiLCJBbW91bnQiLCIiXX0seyJuIjoyLCJjZWxscyI6WyJOb3J0aCIsIkFubiIsIjEyMCIsIiJdfSx7Im4iOjMsImNlbGxzIjpbIlNvdXRoIiwiQm8iLCI4MCIsIiJdfSx7Im4iOjQsImNlbGxzIjpbIk5vcnRoIiwiQ3kiLCIyMDAiLCIiXX0seyJuIjo1LCJjZWxscyI6WyJXZXN0IiwiRGkiLCI1MCIsIiJdfSx7Im4iOjYsImNlbGxzIjpbIlNvdXRoIiwiRWQiLCIxNTAiLCIiXX1dLCJ0YXJnZXQiOlswLDNdfX0%2Cp_Ii9zaGVldHMvcHJhY3RpY2UvcXVlcnki%2Cs_3yI5jgAhUUSTfujU.png"
  "og:image:height": "600"
  "og:image:type": image/png
  "og:image:width": "1200"
  "og:title": "QUERY practice in Google Sheets | ExcelSavvy"
  "twitter:image": "https://excelsavvy.com/_og/d/c_Page%2Ctitle_QUERY%2Bpractice%2Bin%2BGoogle%2BSheets%2Cdescription_~UHJhY3RpY2UgdGhlIEdvb2dsZSBTaGVldHMgUVVFUlkgZnVuY3Rpb246IHNlbGVjdCwgd2hlcmUsIGdyb3VwIGJ5LCBvcmRlciBieSBhbmQgbGltaXQgaW4gYSBsaXZlIGdyaWQu%2Ceyebrow_Google%2BSheets%2Bpractice%2Bexercises%2Csite_practiceexcel%2Cprops_eyJncmlkIjp7ImNvbHMiOlsiQSIsIkIiLCJDIiwiRSJdLCJyb3dzIjpbeyJuIjoxLCJjZWxscyI6WyJSZWdpb24iLCJSZXAiLCJBbW91bnQiLCIiXX0seyJuIjoyLCJjZWxscyI6WyJOb3J0aCIsIkFubiIsIjEyMCIsIiJdfSx7Im4iOjMsImNlbGxzIjpbIlNvdXRoIiwiQm8iLCI4MCIsIiJdfSx7Im4iOjQsImNlbGxzIjpbIk5vcnRoIiwiQ3kiLCIyMDAiLCIiXX0seyJuIjo1LCJjZWxscyI6WyJXZXN0IiwiRGkiLCI1MCIsIiJdfSx7Im4iOjYsImNlbGxzIjpbIlNvdXRoIiwiRWQiLCIxNTAiLCIiXX1dLCJ0YXJnZXQiOlswLDNdfX0%2Cp_Ii9zaGVldHMvcHJhY3RpY2UvcXVlcnki%2Cs_3yI5jgAhUUSTfujU.png"
---

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

# **QUERY practice in Google Sheets**

Ask a table questions in a language much like SQL: pick columns, keep the rows you want, total per group and sort, all with one formula.

[**Start the first exercise**](https://excelsavvy.com/sheets/practice/query/query-select-columns)

QUERY(

## **How the QUERY function works in Google Sheets**

QUERY lets you ask a table questions in a short, SQL-like language. It takes three arguments: the data range, a query written as text in quotes, and optionally the number of header rows. Inside the query, columns are called by letter, A, B, C, counted from the first column of your range, no matter where the range sits on the sheet.

`**=QUERY(A1:C6,"select A, sum(C) group by A")**` totals the Amount column for each region and gives one row per region. To keep only some rows, add where: `**=QUERY(A1:C6,"select B, C where A = 'North'")**` shows the rep and amount for the North region. Text inside the query goes in single quotes, numbers need no quotes.

The parts of a query must come in a fixed order: select, where, group by, order by, limit. Numbers in the query always use a decimal point, whatever language your spreadsheet is set to. Each column should hold one type of data, because a column that mixes numbers and text can come back with blanks. The exercises below cover select, where with numbers and text, group by, and order by with limit.

1. [**1****Pick columns with select**In E1, use QUERY to show the Rep and Amount columns of A1:C6.](https://excelsavvy.com/sheets/practice/query/query-select-columns)
2. [**2****Keep rows with where****Premium**In E1, use QUERY to show the Rep and Amount of every sale over 100.](https://excelsavvy.com/sheets/practice/query/query-where-number)
3. [**3****Match text in where****Premium**In E1, use QUERY to show the Rep and Amount of every sale in the North region.](https://excelsavvy.com/sheets/practice/query/query-where-text)
4. [**4****Totals per group with group by****Premium**In E1, use QUERY to total the Amount for each region.](https://excelsavvy.com/sheets/practice/query/query-group-by-sum)
5. [**5****Top results with order by and limit****Premium**In E1, use QUERY to show the Rep and Amount of the two biggest sales, biggest first.](https://excelsavvy.com/sheets/practice/query/query-order-by-limit)

## **Functions in this topic**

- [**QUERY**](https://excelsavvy.com/sheets/functions/query)

## **Questions**

<details>

<summary>

### How do I use QUERY with data from another sheet?

</summary>

Put the sheet name in front of the range: =QUERY(Sheet2!A1:C6,"select A, B"). For another file, wrap the range in IMPORTRANGE: =QUERY(IMPORTRANGE("spreadsheet URL","Sheet1!A1:C6"),"select Col1, Col3"). Imported columns are called Col1, Col2 and so on instead of A, B, C. The first time, Sheets asks you to allow access between the two files.

</details>

<details>

<summary>

### How do I use QUERY with more than one condition?

</summary>

Join the tests in where with and or or. =QUERY(A1:C6,"select B, C where A = 'North' and C &gt; 100") keeps only North sales over 100. With or, a row stays if it meets either test. When you mix and and or, add parentheses around the tests that belong together so the query reads the way you mean.

</details>

<details>

<summary>

### How do I use a cell value in a QUERY?

</summary>

Break the query text and join the cell in with &amp;. For a number, use =QUERY(A1:C6,"select B, C where C &gt; "&amp;F1). For text, put single quotes around the cell: =QUERY(A1:C6,"select B, C where A = '"&amp;F1&amp;"'"). Change F1 and the result updates.

</details>

```json
{"@context":"https://schema.org","@graph":[{"@id":"https://excelsavvy.com/#identity","@type":"Organization","name":"ExcelSavvy","url":"https://excelsavvy.com/","logo":{"@id":"https://excelsavvy.com/#logo"}},{"@id":"https://excelsavvy.com/#website","@type":"WebSite","inLanguage":"en-US","name":"ExcelSavvy","url":"https://excelsavvy.com/","alternateName":["Excel Savvy","ExcelSavvy.com","PracticeExcel","Practice Excel Online"],"publisher":{"@id":"https://excelsavvy.com/#identity"},"workTranslation":[{"@id":"https://excelopgaver.dk/#website"},{"@id":"https://excelpraxis.de/#website"}]},{"@id":"https://excelsavvy.com/sheets/practice/query#webpage","description":"Practice the Google Sheets QUERY function: select, where, group by, order by and limit in a live grid.","name":"QUERY practice in Google Sheets","url":"https://excelsavvy.com/sheets/practice/query","@type":["WebPage","CollectionPage","FAQPage"],"breadcrumb":{"@id":"https://excelsavvy.com/sheets/practice/query#breadcrumb"},"isPartOf":{"@id":"https://excelsavvy.com/#website"},"mainEntity":[{"@id":"https://excelsavvy.com/sheets/practice/query#/schema/question/1"},{"@id":"https://excelsavvy.com/sheets/practice/query#/schema/question/2"},{"@id":"https://excelsavvy.com/sheets/practice/query#/schema/question/3"}],"potentialAction":[{"@type":"ReadAction","target":["https://excelsavvy.com/sheets/practice/query"]}],"primaryImageOfPage":{"@id":"https://excelsavvy.com/#logo"}},{"@id":"https://excelsavvy.com/sheets/practice/query#breadcrumb","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","name":"Home","item":"https://excelsavvy.com","position":1},{"@type":"ListItem","name":"Google Sheets practice exercises","item":"https://excelsavvy.com/sheets","position":2},{"@type":"ListItem","name":"QUERY practice in Google Sheets","position":3}]},{"@id":"https://excelsavvy.com/sheets/practice/query#/schema/question/1","@type":"Question","inLanguage":"en-US","name":"How do I use QUERY with data from another sheet?","acceptedAnswer":{"@type":"Answer","text":"Put the sheet name in front of the range: =QUERY(Sheet2!A1:C6,\"select A, B\"). For another file, wrap the range in IMPORTRANGE: =QUERY(IMPORTRANGE(\"spreadsheet URL\",\"Sheet1!A1:C6\"),\"select Col1, Col3\"). Imported columns are called Col1, Col2 and so on instead of A, B, C. The first time, Sheets asks you to allow access between the two files."}},{"@id":"https://excelsavvy.com/sheets/practice/query#/schema/question/2","@type":"Question","inLanguage":"en-US","name":"How do I use QUERY with more than one condition?","acceptedAnswer":{"@type":"Answer","text":"Join the tests in where with and or or. =QUERY(A1:C6,\"select B, C where A = 'North' and C > 100\") keeps only North sales over 100. With or, a row stays if it meets either test. When you mix and and or, add parentheses around the tests that belong together so the query reads the way you mean."}},{"@id":"https://excelsavvy.com/sheets/practice/query#/schema/question/3","@type":"Question","inLanguage":"en-US","name":"How do I use a cell value in a QUERY?","acceptedAnswer":{"@type":"Answer","text":"Break the query text and join the cell in with &. For a number, use =QUERY(A1:C6,\"select B, C where C > \"&F1). For text, put single quotes around the cell: =QUERY(A1:C6,\"select B, C where A = '\"&F1&\"'\"). Change F1 and the result updates."}},{"@id":"https://excelsavvy.com/#logo","@type":"ImageObject","caption":"ExcelSavvy","contentUrl":"https://excelsavvy.com/brand/practiceexcel/icon-512.png?v=3","inLanguage":"en-US","url":"https://excelsavvy.com/brand/practiceexcel/icon-512.png?v=3"}]}
```

## Sitemap

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