Using SQL Query in Google Sheets

When using of Google Sheets, you may wonder if it’s possible to use SQL query language to pull up data in Google Sheets, especially when working with large data sets. The answer is yes, it is possible! 

Here is a video below giving examples using the below formula with three different types of Google Sheets sample data sets created by RILLIAN.

Formula:

=QUERY(data, query, headers)

Three Minute Tuesday are a video series by RILLIAN, a consulting agency, briefly, in approximately 3 minutes or less, cover a topic related to work involving Research & Insights Leading to Learning, Innovation, And actioN (R.I.L.L.I.A.N.).

___________________________________________________________________________________________________

One sample data set is an e-commerce store sample data, the second is an epidemiology infectious waterborne disease and exposure sample data set, and the third is a sample videographers log data set.

One type of data that this is useful with is e-commerce data. E-commerce data, like the sample data set shown in this video, has tons of information, all of which is useful in the operations of the store, but looking at all of it can be a little overwhelming. Using the SQL query code above, specific data that you want to look at can be pulled into a separate sheet in the Google Sheets workbook. As you can see in the video, using SQL to do a data query makes it easier to see in which states a certain product, Baby Yoda t shirts, are selling the best in.

Another example is querying data from an epidemiological sample data set. This data set has 2,000 rows with two columns of data. The first column has data on if the person has a confirmed diagnosis of a waterborne disease or not. The second column has data on exposure; if the person had the exposure of swimming in a body of water of interest in this study or if they did not have the exposure. The number one is used to indicate yes and the number zero is used to indicate no.

Using SQL, data can be queried to only pull those who had the diagnosis and had the exposure into a separate sheet in the Google sheets workbook.

Or if you were interested in looking at those who had a confirmed diagnosis but didn’t have the exposure, just change the one to zero, and you can simply adjust the formula and the data query pulls those cases up instead.

A third sample data set is a videographer’s video log. This has all kinds of data that is useful to the videographer, but when just wanting to look at a couple things in the data, such as the take number of a video clip (takes are the number of times that scene was filmed to get it to be just right), it can be useful to do a data query and pull that data into a separate sheet in the Google sheet workbook, as shown in the video.

As you can see, there are many ways this type of data query language can be useful in a variety of different types of data sets in Google Sheets.

Have you used SQL in Google Sheets? What kind of data set did you analyze? Did you find SQL  to be helpful for the data set you were working with? 

Leave a comment below!

Resource:

A great resource on using this particular type of SQL formula in Google Sheets, is reading Ben Stockton’s article “How to Use the Query Function in Google Sheets” available at https://www.howtogeek.com/450465/how-to-use-the-query-function-in-google-sheets/

Leave a Reply

Your email address will not be published. Required fields are marked *