---
title: "NEW COURSE: Mastering the QUERY Function in Google Sheets"
author: "Martin Hawksey"
date: 2022-05-18T10:26:38+00:00
modified: 2022-05-18T10:26:44+00:00
canonical_url: https://pulse.appsscript.info/p/2022/05/new-course-mastering-the-query-function-in-google-sheets/
markdown_url: https://pulse.appsscript.info/p/2022/05/new-course-mastering-the-query-function-in-google-sheets.md
categories:
  - "Comment"
  - "Community News"
  - "Sheets"
  - "Solutions"
tags:
  - "@benlcollins"
  - "benlcollins.com"
  - "Editor"
featured_image: https://pulse.appsscript.info/files/2022/05/whereFilter3-1.gif
description: "Friend of Pulse and Google Sheets guru, Ben Collins, has a new course ‘The QUERY Function in Google Sheets’. The QUERY function it lets you perform various data manipulations making it easy to reshape, aggregate and explore your data in Google Sheets. The course is designed to be suitable for everyone from beginner to advanced who are interested in ways to work more effectively with your data. This Pulse post includes information on how to get a 50% on the course and also a snippet showing how you can using the QUERY language in Google Apps Script."
---

# NEW COURSE: Mastering the QUERY Function in Google Sheets

![NEW COURSE: Mastering the QUERY Function in Google Sheets](https://pulse.appsscript.info/files/2022/05/whereFilter3-1.gif)

> Image credit: Ben Collins (benlcollins.com)
> Master the QUERY function, the most powerful function in Google Sheets, to become a more effective data analyst

Friend of Pulse and Google Sheets guru, Ben Collins, has a new course ‘The QUERY Function in Google Sheets’. The [`QUERY` function**](https://support.google.com/docs/answer/3093343) it lets you perform various data manipulations making it easy to reshape, aggregate and explore your data in Google Sheets. The course is designed to be suitable for everyone from beginner to advanced who are interested in ways to work more effectively with your data.

If you are not familiar with the QUERY function Ben provides one example of what is possible in [Sheets Tip 204: How To Use Dates In The QUERY Function**](https://benlcollins.ck.page/posts/sheets-tip-204-how-to-use-dates-in-the-query-function) (check the linked post in this Sheet Tip for an example worksheet).

> **Bonus:** [Sheets Tip 204](https://benlcollins.ck.page/posts/sheets-tip-204-how-to-use-dates-in-the-query-function) includes a 50% discount on the course valid until Friday 20 May 2022 at midnight EDT.

Finally, if you are interested in using the QUERY language in Google Apps Script it is possible! Below is some code used in [this copy of Ben’s example workbook**](https://docs.google.com/spreadsheets/d/1BBmxj-ZNqh-ddBVdqTWEyN5tL0ApZxNAlVMqdIhhpWk/copy) based on:

```
// based on https://gist.github.com/tanaikech/053d3ebbe76fa7c0b5e80ea9d6396011#sample-script

function myFunction() {
 const doc = SpreadsheetApp.getActive()
 const spreadsheetId = doc.getId(); // or set another Spreadsheet ID.
 const sheetId = doc.getSheetByName('Data').getSheetId(); // or set another Sheet ID from Spreadsheet ID.

 const query = "select C, B where B > date '2000-01-01' and B <= date '2002-12-31'"; // your QUERY

 const url = `https://docs.google.com/spreadsheets/d/${spreadsheetId}/gviz/tq?tqx=out:csv&gid=${sheetId}&tq=${encodeURI(query)}&access_token=${ScriptApp.getOAuthToken()}`;

 const res = UrlFetchApp.fetch(url,);
 console.log(res.getContentText());

 const array = Utilities.parseCsv(res.getContentText());
 console.log(array);

 // SpreadsheetApp.getActiveSpreadsheet(); // This comment line is put for automatically detecting the scopes if directly adding a spreadsheet ID.
}
```

Source: *[The QUERY Function in Google Sheets*](https://courses.benlcollins.com/p/the-query-function-in-google-sheets)

---

*Published by [Martin Hawksey](https://pulse.appsscript.info/p/author/admin/) on [Pulse](https://pulse.appsscript.info/). Original article: [https://pulse.appsscript.info/p/2022/05/new-course-mastering-the-query-function-in-google-sheets/](https://pulse.appsscript.info/p/2022/05/new-course-mastering-the-query-function-in-google-sheets/)*
