
We’ll walk through some of these examples below. There are various key commands (which need to be done in the right order) to pull data. The QUERY function in Google sheets uses a type of SQL (usually a database language) to wrangle spreadsheet data.
#GOOGLE SHEETS HOW TO#
How To Use The QUERY Function in Google Sheets Looking up keywords based on specific criteria.Quickly sorting and filtering large datasets.The WHERE clause determines from which row is the result returns, while the SELECT clause determines from which columns. The WHERE clause works with logical operators (,, =, ) or string operators (contains, starts with, matches, etc.). The function searches for the results according to this filter and returns the values that meet your conditions. It returns only the rows that match a condition, so it works as a filter. The most common clause is the WHERE clause. “ SELECT *” returns all the columns of the sheet. It specifies which columns you want to return and in which order.įor example, “ SELECT B D G” returns the results from the columns B, D and G. The SELECT clause is the first clause that you start your queries with. The clauses tell the query what to do with the data and what you want the function to return. If you don’t set anything, Google Sheets guesses the value based on the content of data. It tells the function how many header rows should be excluded from the search. The optional headers argument indicates the number of header rows in your data.It’s the main part of the QUERY function. It must be written in the query language and enclosed in double-quotes. The second argument, query, contains the actual query that specifies what you’re looking for.The first argument is data which the range of cells from where you query the data.The function takes two required arguments and the third one is optional: The QUERY function in Google Sheets is like bringing a gun to a knife fight. It’s very similar to the SQL (Structured Query Language), the widely used database language. This language is used to ask details about the data set, so you can look up and filter your data in any format.


When using the QUERY function, you have to write the queries with the Google Visualization API Query Language, which is a special database-like language. It can replace many other functions like IF, FIND, VLOOKUP, SEARCH and others because it can perform queries that are not possible or not so easy to do with other functions. The QUERY function is considered to be the most powerful function in Google Sheets. How To Use The QUERY Function in Google Sheets.
